Home > PowerCLI, PowerShell, VMware, vSphere > Create an ‘Internal’ vSwitch with PowerCLI

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 🙂

image

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 😦

image

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!

  1. February 19, 2012 at 19:35

    Thanks – was lookin all ovet for this!

  1. No trackbacks yet.

Leave a comment