Migrate Virtual Machine Networking Configuration from a vSphere Standard Switch to a vSphere Distributed Switch

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

  1. Get the source vSphere standard switch from which you want to migrate the virtual machine networking.
    $virtualSwitch = Get-VirtualSwitch -Name 'MyVirtualSwitch'
  2. Get the source standard port group to which the virtual machines are connected.
    $vmsPortGroup = $virtualSwitch | Get-VirtualPortGroup -Name 'VM Network'
  3. Get the target vSphere distributed switch to which you want to migrate the virtual machine networking.
    $vdSwitch = Get-VDSwitch -Name 'MyTargetVDSwitch'
  4. Get the target port group to which you want to connect the virtual machines.
    $vdPortGroup = Get-VDPortGroup -VDSwitch $vdSwitch -Name 'DPortGroup'
  5. Get the virtual machine network adapters connected to the source port group.
    $vmsNetworkAdapters = Get-VM -RelatedObject $vmsPortGroup | Get-NetworkAdapter | where { $_.NetworkName -eq $vmsPortGroup.Name }
  6. Disconnect the retrieved network adapters from the standard port group and connect them to the distributed port group.
    Set-NetworkAdapter -NetworkAdapter $vmsNetworkAdapters -PortGroup $vdPortGroup