Create an ‘Internal’ vSwitch with PowerCLI
I was looking for the correct syntax to create a vSwitch with PowerCLI which has no vmnics attached (aka: Internal vSwitch).
I tried to run the following cmdlet. The pNIC’s are specified with the –Nic parameter.
Get-VirtualSwitch -VMHost "ServerName" -Name "vSwitchName" | Set-VirtualSwitch -Nic "" -Confirm:$false
But this resulted in a nice error 🙂
Okay, so it doesn’t accept empty strings… Let’s try to feed it with a $null value
Get-VirtualSwitch -VMHost "ServerName" -Name "vSwitchName" | Set-VirtualSwitch -Nic $null -Confirm:$false
And guess what: a different error 😦
The –NIC parameter accepts string values or an array of strings. So let’s try to throw an empty array at it:
Get-VirtualSwitch -VMHost "ServerName" -Name "vSwitchName" | Set-VirtualSwitch -Nic @() -Confirm:$false
That’s more like it! Now the switch is updated and all vmnics are removed from it!
Categories: PowerCLI, PowerShell, VMware, vSphere
Thanks – was lookin all ovet for this!