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 🙂


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!

  1. February 19, 2012 at 19:35

    Thanks – was lookin all ovet for this!

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: