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.

Pre-requisites

  • PowerCLI 6.5 or above
  • Powershell

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.

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.