I’m currently running a project to consolidate a sprawl of VM farms which are underutilised, down to a much smaller number, and a significant reduction in host numbers. The first cluster I’ve started work on had a non-standard naming convention for the Port Groups, so prior to moving this needs correcting.
First I’ve added new Port groups with the correct names, then I knocked up a quick PowerCLI script to move all the VMs:
$vms = Get-Cluster "Cluster1" | Get-VM foreach ($vm in $vms) { $nics = $vm | Get-NetworkAdapter foreach ($nic in $nics) { $nic if ( $nic.NetworkName -eq "1st_old_name") { Set-NetworkAdapter $nic -NetworkName "1st_new_name" -Confirm:$false } if ( $nic.NetworkName -eq "2nd_old_name") { Set-NetworkAdapter $nic -NetworkName "2nd_new_name" -Confirm:$false } } }
This cycles through each of the VMs in the cluster, and moves each adapter on the old name to the new name.