Fout bij Netwerkswitchbeheer-CmdletsNetwork Switch Manager Cmdlets Failure

De cmdlets Netwerkswitchbeheer kan worden gebruikt voor het beheren van netwerkswitches via WSMAN.The Network Switch Manager cmdlets can be used to manage network switches over WSMAN. Enkele cmdlets van deze module zijn geschikt voor het accepteren van waarden van pijplijnen.A few cmdlets of this module are capable of accepting values from pipelines. WMF 5.1 Preview-versie mislukt de cmdlets die de waarde van de pijplijn kan accepteren om uit te voeren wanneer de waarden niet via pijplijnen doorgegeven worden.In WMF 5.1 Preview, the cmdlets that can accept value from pipeline fail to execute when the values are not passed through pipelines.

Als de parameter 'InputObject' niet gebruikt wordt, moet de cmdlet blijven uitvoeren zonder fouten.If "InputObject" parameter is not used, the cmdlet should continue to execute without failures.

Hier volgt de lijst van betreft de cmdlets dat wil zeggen deze cmdlets kunt accepteren waarde voor parameter 'InputObject' van de pijplijn.Here is the list of affected cmdlets i.e. these cmdlets can accept value for "InputObject" parameter from pipeline. Als deze waarde niet is doorgegeven door de pijplijn mislukt de uitvoering van de cmdlet.If this value is not passed from pipeline the execution of cmdlet will fail.

  • Disable-NetworkSwitchEthernetPortDisable-NetworkSwitchEthernetPort
  • Enable-NetworkSwitchEthernetPortEnable-NetworkSwitchEthernetPort
  • Remove-NetworkSwitchEthernetPortIPAddressRemove-NetworkSwitchEthernetPortIPAddress
  • Set-NetworkSwitchEthernetPortIPAddressSet-NetworkSwitchEthernetPortIPAddress
  • Set-NetworkSwitchPortModeSet-NetworkSwitchPortMode
  • Set-NetworkSwitchPortPropertySet-NetworkSwitchPortProperty
  • Disable-NetworkSwitchFeatureDisable-NetworkSwitchFeature
  • Enable-NetworkSwitchFeatureEnable-NetworkSwitchFeature
  • Remove-NetworkSwitchVlanRemove-NetworkSwitchVlan
  • Set-NetworkSwitchVlanPropertySet-NetworkSwitchVlanProperty

OplossingResolution

De cmdlets werken prima als de waarde van parameter InputObject erin worden doorgegeven via de pijplijn.The cmdlets work fine when the value of InputObject parameter are passed into it through pipeline. Er zijn enkele voorbeelden die voor de bovenstaande cmdlets werken: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