Migrate VMkernel Ports from 1000v or VDS to Standard Switch using Powercli

Migrate Host and Guests VDS to SS using Powercli 5.5

On occasion, we have a need to be able to remove an ESXi host from our distributed switch to a standard switch. In order to do this you can go through the GUI and choose “Migrate” adapters shown in the screen shot below. The command below assumes that you already have at least 1 physical adapter on both the VDS and Standard Switch. That part can be scripted out as well to move one interface over first, migrate vmkernel ports, and then the other interface.

In my case we need to get hosts from a 4.x Vcenter to a 5.x Vcenter along with all the guests. I will detail this migration to get guests/hosts and script used in a later posting located here.


This requires multiple clicks and can be tedious if you have multiple hosts that need to be done.  Currently, there is no way that I know of to migrate VMkernel networking from DVS to SS in powercli.  You can go the other direction using the new DVS cmdlet Set-VMHostNetworkAdapter and the port group option.

I wrote a cmdlet to migrate vmkernel ports from DVS to standard. Here it is and the usage:

MigrateDVSwitch-Adapter -VMHost host -Interface vmk1 -NetworkName Vmotion -VirtualSwitch vSwitch -Vlan 77

function MigrateDVSwitch-Adapter{
        #Specify Parameters, VMhostname, VMkernel interface, Network Name, Vlan ID, Standard Switch nameparam (

        #Get esxi object
        $VMHostobj = Get-VMHost $VMHost
	#Get Network ID
	$networkid = $VMHostObj.ExtenSionData.Configmanager.NetworkSystem

        # ------- AddPortGroup to Standard Switch
	$portgrp = New-Object VMware.Vim.HostPortGroupSpec
	$portgrp.name = $NetworkName
	$portgrp.vlanId = $Vlan
	$portgrp.vswitchName = $VirtualSwitch
	$portgrp.policy = New-Object VMware.Vim.HostNetworkPolicy
	$_this = Get-View-Id $networkid

        # ------- UpdateVirtualNic ----Migrates the virtual interface to the standard switch
	$nic = New-Object VMware.Vim.HostVirtualNicSpec
	$nic.portgroup =$NetworkName
	$_this = Get-View-Id $networkid
	$_this.UpdateVirtualNic($Interface, $nic)


4 Responses to Migrate VMkernel Ports from 1000v or VDS to Standard Switch using Powercli

  1. Dmitry says:

    How it can make via hands from vsphere client?

  2. None says:

    Thank you for this command let.
    There is a fata syntax error though (probably due to HTML transation). The command “Get-View-Id” needs to be “Get-View -Id” with a space between View and -Id

  3. The Todd says:

    this functionality exists in the 6.5 webclient now.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: