Batch migrate VM’s with VMware Cross vCenter vMotion (Fling)

VMware already features Cross vCenter Migrations since vSphere 6.0. The biggest constraint for this feature is that you can’t use it via the vSphere Web Client if the vCenter Server instances are not in Enhanched Linked Mode and within the same vCenter Single Sign-On domain. (a full list of requirements can be found here.)

If vCenter Server instances are in different SSO domains VMware does give you the ability to use vSphere API/SDK,  but for most of us the usage of API/SDK is hard to understand.

This is where a VMware Fling called “Cross vCenter Workload Migration Utility” (XVM) steps in:

This utility allows users to easily migrate virtual machines in bulk from a graphical user interface between vCenter servers using the Cross-vCenter vMotion feature.

So if you want to migrate/clone some VM’s around, I do encourage you to test this tool as the GUI actually works very well. (version 2.5). However if you want to batch migrate VM’s this GUI might not be the best option available and you easily end up in using scripting.

I will not describe the usage of the XVM tool itself as this is fully documented on the Fling website and within this excellent article of William Lam, which also shows a lot of PowerCLI examples and which even delivers a PowerCLI Script Module for XVM.

What I will share in this article is my bundle of PowerCLI scripts and input files, that allowed me to batch migrate a huge amount of VM’s.
My PowerCLI scripts use William Lam’s PowerCLI Script Module for XVM so be sure to ready through his article first for a common understanding of it all.

My bundle can be dowloaded here: XVM_Scripts and contains these files:

File instruction
XVM-New.psm1 This is William Lam’s Powershell Script Module, with a small adjustment for my set of files to work correctly with each other.
XVM-RegistervCenter.ps1 Change the VARIABLES section within this file to match your needs.


# ————————————————————————-
# ————————————————————————-
#Variables to match Source and Destination site name in XVM
$SRCSite = “vcenter01.test.local”
$DSTSite = “vcenter02.test.local”
$VCUSER = “username”

XVM-Migrate.ps1 Change the VARIABLES section within this file to match your needs.


# ————————————————————————-
# ————————————————————————-
#Variables to match Source and Destination site name in XVM
$SRCSite = “vcenter01.test.local”
$DSTSite = “vcenter02.test.local”

#OperationType: Relocate or Clone
$OperationType = “Relocate”

$SRCDatacenter = “datacenter01”
$DSTDatacenter = “datacenter02”
$DSTCluster = “cluster01”
$DSTDatastore = “datastore01”
$DSTFolder = “dest-folder”

#Input Files
$NWInput = “C:\Fling\XVM\Input-NetworkMappings.csv”
$VMInput = “C:\Fling\XVM\Input-VM.csv”

input-VM.csv Input File which contains the VM’s that a action is needed for. (i.e. all VM’s that need to be migrated/cloned)

→ Note that this .csv file doesn’t contain a header

input-NetworkMappings.csv Input File which lists the network mappings: source portgroup → destination portgroup.

→ Note that this .csv does contain a header “srcnetwork,dstnetwork”

When having it all set its simply a matter of:

  1. Ensuring the Java app is started;
  2. First execute the .\XVM-RegistervCenter.ps1 to register the vCenter Server instances;
  3. Execute the .\XVM-Migrate.ps1 to start the actual migration.

A successful initiated job gives you:

A unsuccessful iniated job gives you:

When this happens take a close look at the output of the Java app which shows you what is going wrong. For instance, you are trying to migrate a VM that is not existing on the source vCenter Server:

Happy migrating!

Leave a Reply

%d bloggers like this: