vMotion between two vCenter Servers with different SSO domains

Last week i did my first vMotion between two vCenter Servers with different SSO domain by using PowerCLI. This functionality is also known as “cross vCenter vMotion” and is not included in the vSphere Web Client yet. Without downtime it’s possible to live migrate VMs from one vCenter Server to another. Cool stuff!

Before starting the following requirements must be met:

  • VMware vSphere 6.0 and later for the source and destination environment
  • PowerCLI 6.5¬†and later
  • vSphere Enterprise Plus license per ESXi host
  • An active connection to the source and destination¬† vCenter Server

I created a simple script to vMotion the VMs between the two SSO domains. See the more information section for more advanced PowerCLI scripts from for example William Lam and Romain Decker.

In the script the following variables must be defined:

  • Source vCenter Server, username and password
  • Destination vCenter Server, username and password
  • VM name will be moved
  • Destination vSwitch
  • Destination Portgroup
  • Destination datastore

Only VMs with one NIC are supported

PowerCLI example script

Import-Module VMware.PowerCLI
$sourceVC = 'sourcevc'
$sourceVCUsername = 'administrator@vsphere.local'
$sourceVCPassword= 'password!'
$destVC = 'destinationvc'
$destVCUsername = 'administrator@vsphere.local'
$destVCPassword= 'password'
$destESXi = 'destinationesxi'
$vmname = 'vmname'
$Switchname = 'destinationswitch'
$NetworkName = 'destinationvlan'
$datastorename = 'destinationdatastore'
# Connect to the vCenter Servers
$sourceVCConn = Connect-VIServer -Server $sourceVC -user $sourceVCUsername -password $sourceVCPassword
$destVCConn = Connect-VIServer -Server $destVC -user $destVCUsername -password $destVCPassword
$vm = Get-VM $vmname -Server $sourceVCConn
$networkAdapter = Get-NetworkAdapter -VM $vm -Server $sourceVCConn
$destination = Get-VMHost -name $destESXi -Server $destVCConn
$destinationPortGroup = Get-VirtualPortGroup -VirtualSwitch $Switchname -name $NetworkName -VMHost $destination
$destinationDatastore = Get-Datastore -name $datastorename -Server $destVCConn
Move-VM -VM $vm -Destination $destination -NetworkAdapter $networkAdapter -PortGroup $destinationPortGroup -Datastore $destinationDatastore

With this script I migrated a couple of VMs between to vSphere 6.5 environment with different SSO domains without any downtime.

More information:

  • PowerCLI blog on the Move-VM cmdlet, link
  • William Lam, Automation Cross vCenter vMotion, link
  • Romain Decker Cross vMotion script from, link

1 thought on “vMotion between two vCenter Servers with different SSO domains”

  1. Works just fine! One question though: I get this warning:

    “WARNING: The output of the command produced distributed virtual portgroup
    objects. This behavior is obsolete and may change in the future. To retrieve
    distributed portgroups, use Get-VDPortgroup cmdlet in the VDS component. To
    retrieve standard portgroups, use -Standard.”

    I tried to exchange the command I suspected, Get-VirtualPortGroup -VirtualSwitch, for this command, Get-VDPortgroup -VDSwitch, but then I get the red error message:

    “Get-VDPortgroup : Cannot bind parameter ‘VMHostNetworkAdapter’. Cannot convert the “esxihg1001.kb.local” value of type “VMware.VimAutomation.ViCore.Impl.V1.Inventory.VMHostImpl” to type “VMware.VimAutomation.ViCore.Types.V1.Host.Netw
    At \\kb.local\data\Users\hentho\Mina dokument\WindowsPowerShell\Scripts\CrossVmotion.ps1:26 char:90
    + … rtgroup -VDSwitch $Switchname -name $NetworkName -VMHost $destination
    + ~~~~~~~~~~~~
    + CategoryInfo : InvalidArgument: (:) [Get-VDPortgroup], ParameterBindingException
    + FullyQualifiedErrorId : CannotConvertArgumentNoMessage,VMware.VimAutomation.Vds.Commands.Cmdlets.GetVDPortgroup”

    But, the vMotion operation still gets through?

    As everything works, this is no biggie, but I would like to avoid both warning as well as error messages if possible. Any help?

Leave a Comment