Site icon

Migrate VM between two vCenter joined to different SSO domain


Cross vCenter vMotion capability have been introduced sine vSphere 6.0. But, what if vCenter servers are joined to different SSO (single signon) domain. You will not get option in GUI to migrate VM to different vCenter then. So, is it still possible to do migration between them. In this blog, we will see how to migrate VM in such scenario.


Script to Execute

Import-Module VMware.PowerCLI
$srcvCenter = '<source vCenter name>'
$srcvCenterUsr = '<vCenter user name>'
$srcvCenterPwd= '<password>'
$dstvCenter = '<destination vCenter name>'
$dstvCenterUsr = '<vCenter user name>'
$dstvCenterpwd = '<password>'
$dstESX = '<destination ESXi Host>' 
$vmname = 'test'
$vswitch = '<vDS or vSS name>'
$vmportgrp = '<Destination portgroup name>'
$datastorename = '<Destination datastore name>'

$srcvCentercon = Connect-VIServer -Server $srcvCenter -user $srcvCenterUsr -password $srcvCenterPwd
$dstvCentercon = Connect-VIServer -Server $dstvCenter -user $dstvCenterUsr -password $dstvCenterpwd

$vm = Get-VM $vmname -Server $srcvCentercon
$vmnetwork = Get-NetworkAdapter -VM $vm -Server $srcvCentercon
$dstattr = Get-VMHost -name $dstESX -Server $dstvCentercon
$dstNwPort = Get-VirtualPortGroup -VirtualSwitch $vswitch -name $vmportgrp -VMHost $dstattr
$dstDatastore = Get-Datastore -name $datastorename -Server $dstvCentercon

Move-VM -VM $vm -Destination $dstattr -NetworkAdapter $vmnetwork -PortGroup $dstNwPort -Datastore $dstDatastore

Using script above, we can easily migrate VMs between two vCenter servers joined to different SSO domain.

Let me know your thoughts.

Exit mobile version