To manage virtual machine networks on a data center level, you might need to migrate existing networks from vSphere standard switches to vSphere distributed switches.
Prerequisites
Verify that you are connected to a vCenter Server system.
Procedure
- Get the source vSphere standard switch from which you want to migrate the virtual machine networking.
$virtualSwitch = Get-VirtualSwitch -Name 'MyVirtualSwitch'
- Get the source standard port group to which the virtual machines are connected.
$vmsPortGroup = $virtualSwitch | Get-VirtualPortGroup -Name 'VM Network'
- Get the target vSphere distributed switch to which you want to migrate the virtual machine networking.
$vdSwitch = Get-VDSwitch -Name 'MyTargetVDSwitch'
- Get the target port group to which you want to connect the virtual machines.
$vdPortGroup = Get-VDPortGroup -VDSwitch $vdSwitch -Name 'DPortGroup'
- Get the virtual machine network adapters connected to the source port group.
$vmsNetworkAdapters = Get-VM -RelatedObject $vmsPortGroup | Get-NetworkAdapter | where { $_.NetworkName -eq $vmsPortGroup.Name }
- Disconnect the retrieved network adapters from the standard port group and connect them to the distributed port group.
Set-NetworkAdapter -NetworkAdapter $vmsNetworkAdapters -PortGroup $vdPortGroup