The Network Switch Manager cmdlets can be used to manage network switches over WSMAN. A few cmdlets of this module are capable of accepting values from pipelines. In WMF 5.1 Preview, the cmdlets that can accept value from pipeline fail to execute when the values are not passed through pipelines.

If "InputObject" parameter is not used, the cmdlet should continue to execute without failures.

Here is the list of affected cmdlets i.e. these cmdlets can accept value for "InputObject" parameter from pipeline. If this value is not passed from pipeline the execution of cmdlet will fail.

  • Disable-NetworkSwitchEthernetPort
  • Enable-NetworkSwitchEthernetPort
  • Remove-NetworkSwitchEthernetPortIPAddress
  • Set-NetworkSwitchEthernetPortIPAddress
  • Set-NetworkSwitchPortMode
  • Set-NetworkSwitchPortProperty
  • Disable-NetworkSwitchFeature
  • Enable-NetworkSwitchFeature
  • Remove-NetworkSwitchVlan
  • Set-NetworkSwitchVlanProperty

Resolution

The cmdlets work fine when the value of InputObject parameter are passed into it through pipeline. A few examples that work for the above cmdlets are:

  • Disable-NetworkSwitchEthernetPort

    $port = Get-CimInstance -Namespace root/interop -ClassName CIM_EthernetPort -CimSession $cimSession | Select-Object -First 1
    $port | Disable-NetworkSwitchEthernetPort -CimSession $cimSession
    
  • Enable-NetworkSwitchEthernetPort

    $port = Get-CimInstance -Namespace root/interop -ClassName CIM_EthernetPort -CimSession $cimSession | Select-Object -First 1
    $port | Enable-NetworkSwitchEthernetPort -CimSession $cimSession
    
  • Remove-NetworkSwitchEthernetPortIPAddress

    $port = Get-CimInstance -Namespace root/interop -ClassName CIM_EthernetPort -CimSession $cimSession | Select-Object -First 1
    $port | Remove-NetworkSwitchEthernetPortIPAddress -CimSession $cimSession
    
  • Set-NetworkSwitchEthernetPortIPAddress

    $port = Get-CimInstance -Namespace root/interop -ClassName CIM_EthernetPort -CimSession $cimSession | Select-Object -First 1
    $ipAddress = "192.168.10.1"
    $subnetAddress = "255.255.255.0"
    $port | Set-NetworkSwitchEthernetPortIPAddress -IpAddress $ipAddress -SubnetAddress $subnetAddress -CimSession $cimSession
    
  • Set-NetworkSwitchPortProperty

    $portProperties = @{Caption = "New Caption"}
    $port = Get-CimInstance -Namespace root/interop -ClassName CIM_EthernetPort -CimSession $cimSession | Select-Object -First 1
    $port | Set-NetworkSwitchPortProperty -Property $portProperties -CimSession $cimSession
    
  • Disable-NetworkSwitchFeature

    $feature = Get-CimInstance -Namespace root/interop -ClassName MSFT_Feature -CimSession $cimSession | Select-Object -First 1
    $feature | Disable-NetworkSwitchFeature -CimSession $cimSession
    
  • Enable-NetworkSwitchFeature

    $feature = Get-CimInstance -Namespace root/interop -ClassName MSFT_Feature -CimSession $cimSession | Select-Object -First 1
    $feature | Enable-NetworkSwitchFeature -CimSession $cimSession
    
  • Set-NetworkSwitchVlanProperty

    $properties = @{Caption = "New Caption"}
    $vlan = Get-CimInstance -ClassName CIM_NetworkVlan -Namespace root/interop -CimSession $cimSession | Select-Object -First 1
    $vlan | Set-NetworkSwitchVlanProperty -Property $properties -CimSession $cimSession