Solving problems invented by others...
Renaming vSwitch port groups

Renaming vSwitch port groups

After my try to rename port groups on a vSwitch yesterday i want to share my experiences.

(Please don´t ask why i still use a vSwitch instead of a dvSwitch in one of my clusters. That´s another story…)


While renaming a port group on a dvSwitch is no problem (KB#2048035), the same task on a vSwitch seems to be more complicated. I found now way to simply rename a port group without causing issues with VMs connected to it. The right way seems to create a new port group with the same VLAN settings and move over all VMs to the new port group and delete the old one. This is an option if you have only a few VMs. But in my case i had around 100 VMs and i don´t want to spend a few hours on this task.

So here´s what i did:

1.) Create a new port group on all hosts in the cluster

Get-Cluster -Name "Name of my cluster" | Get-VMHost | Get-VirtualSwitch -Name "vSwitch0" | New-VirtualPortGroup -Name "new-port-group" -VLanId 1234

Replace the VLAN ID with the right one for your environment.

2.) Move over all VMs from the old to the new port group

Get-Cluster -Name "Name of my cluster" | Get-VM | Get-NetworkAdapter | Where-Object -FilterScript { $_.NetworkName -eq "old-port-group" } | Set-NetworkAdapter –NetworkName “new-port-group” -Confirm:$false

3.) Delete the old port group from all hosts in the cluster

Get-Cluster -Name "Name of my cluster" | Get-VMHost | Get-VirtualSwitch -Name "vSwitch0" | Get-VirtualPortGroup -Name "old-port-group" | Remove-VirtualPortGroup -Confirm:$false

4.) Clean up the mess

You might see that the old port group is still shown in the network tab. When you check the VMs that are still belonging to this old port group you see that they are assigned to both, the old and the new port group. Even if they have only one virtual network card.

The cause is that these VMs have snapshots and in that snapshots the old network name is still present. (KB#2020052)

So simply delete the snapshots and your done!

Leave a Reply

Your email address will not be published.

thirty nine ÷ = thirteen