Set-VirtualSwitch and a Misunderstanding

I was doing some installations yesterday – and I wanted to add a second NIC to a vSwitch on a set of newly installed servers. Of course there were 10 of them, and I did not want to do this manually.

Easiest way to do it (besides installing them with a script correctly in the first place) was with PowerCLI.

From the Set-VirtualSwitch help:

--------------  Example 3 --------------

C:\PS>Get-VMHost *.128 | Get-VirtualSwitch | Select-Object -First 1 | Set-VirtualSwitch -Nic vmnic5

Add a physical network adapter named 'vmnic5' to the first switch of the host. Note that the 'vmnic5' adapter must not be assigned to other virtual switches.

What I understand from that – you add an additional NIC to the vSwitch – it leaves the current assignment alone, it just adds another.

And this is how I started out.


So I set out to add vmnic1 to the vSwitch

Get-VirtualSwitch -Name vSwitch0 | Set-VirtualSwitch -Nic vmnic1

The command completed successfully – but look what happened:


Now this is weird part. In the DCUI – I had no NIC’s selected for the management network.

The case I had yesterday was that the transition on the switches was not fast enough – and I lost connection to the host. ILO was needed to fix it.

But back to this morning. I tried this on a workstation vESX and it produced to different results.

After running this command I was presented in the DCUI with the screen shot above but strangely enough I still had connection to the host.

ESXi Shell showed this:

Only vmnic1

Which was weird if you ask me.

I restarted the management Network through the DCUI and still had the same screen as before but I had now lost connection to the network

Lost Connection

I then added vmnic0 back into the vSwitch through the DCUI

Add vmnic0

I got my connection back..

Ping works

But strangely enough in the vSphere client I saw this.

vSphere Client

Which struck me as strange. I had this in the ESXi Shell


And now I finally understood what was happening.. The uplink was added to vSwitch0 – but not to the management network Portgroup, which personally I find strange.

What I actually should have done was this.

Get-VirtualSwitch -Name vSwitch0 | Set-VirtualSwitch -Nic vmnic0,vmnic1

This would add the second vmnic to the first – and would not have caused me all this trouble, and produced this:


vSphere Client


So what can I (and perhaps you) learn from this whole episode?

  1. As always.. Test!! Test!! Test!!!
  2. The help could be more accurate (ahem… PowerCLI people…
  3. Investigating a problem in depth – gives you a better understanding of what is going on.

Now if someone could possibly explain why the host behaved exactly the way it did, I would be grateful. Also why the default behavior of the PowerCLI command did what it did – would be also appreciated..

Hope you enjoyed the ride…