Finding and fixing VMs connected to missing port groups.

Yesterday someone took the liberty of upgrading one of my ESX servers that I use to run a virtual vSphere lab. Fortunately he was kind enough to preserve all of the VMs, and they were restored and re-registered after the upgrade.

There was one detail that he didn’t notice, which was that my virtual vSphere lab VMs were all connected to an internal network called “Internal”. When I got in today my lab didn’t work at all because there was no networking between vCenter and the ESX hosts or their shared storage. The network cards all said they were attached to the “Internal” network, but there was no Internal network! Fortunately this was pretty easy to fix with PowerCLI.

First, let’s look at a script that will identify any VM that is connected to a non-existent network:

This code starts by getting a list of all portgroup names. Then it goes through all VMs and identifies any VM that has at least one network adapter connected to a non-existent portgroup. Note that this assumes we are connected directly to ESX. If you need to use something like this against vCenter you should do it on a host-by-host basis. Anyway, when I ran it here was the result:


These are all the VMs of my virtual lab. Now let’s go about fixing the problem. First, creating the Internal virtual switch and portgroup are pretty easy:

Now the portgroup exists but there is one last problem: the VMs are not actually connected to the portgroup. Again, pretty easy to fix.

With that, everything is back to normal.


2 comments have been added so far

  1. When you play games, you really thought about the Department of your equipment well enough, your account than others, your gold enough … There are better! What you want to have here.come on..Let’s go

  2. I did this to find a vm with a specified mac-address:
    get-vm | where { $_ | Get-NetworkAdapter | where { $_.macaddress -eq “00:50:56:bf:65:7e” } }

Leave a Reply

Your email address will not be published. Required fields are marked *