PSxVCvMotion - Cross vCenter vMotion


This a Powershell / PowerCLI module for automating Cross vCenter vMotion. It is build to help migrate a lot of VM with heterogeneous configurations. By default it will assume that configurations are the same between the source and target vCenter. Optionnaly you can define targets for specifics items (portgroups, datastores).

The parameters needed for the vMotions are stored inside of a .ps1 file. They will be automatically tested before starting any vMotion.

This module is build with the modern and open sourced Powershell's tools Pester and PSake.

Special Thanks

A big shout out to William Lam and Kyle Ruddy for there blog articles about cross vCenter vMotion:

Known limitations

  • You can only start vMotion between clusters.
  • There's no check to test if resources are available (CPU, RAM and storage).


Install the module

#Automated installation (Powershell 5):
    Install-Module PSxVCvMotion -Scope CurrentUser

# Or manual setup
    # Download the repository
    # Unblock the zip
    # Extract the PSxVCvMotion folder to a module path (e.g. $env:USERPROFILE\Documents\WindowsPowerShell\Modules\)

# Import the module
    Import-Module PSxVCvMotion  #Alternatively, Import-Module \\Path\To\PSxVCvMotion

# Get commands in the module
    Get-Command -Module PSxVCvMotion

Run the script

  1. Edit or create a config file.The file need to be created with the .ps1 extension. An example is available in \Path\To\PSxVCvMotion\Configs\Config.ps1
  2. Run the script in test mode.
> Invoke-xVCvMotion -Config \\Path\To\Config.ps1
  1. If everything works well, start the migration by adding the Migrate parameter.
> Invoke-xVCvMotion -Config \\Path\To\Config.ps1 -Migrate

Configuration file

An example is available in \Path\To\PSxVCvMotion\Configs\Config.ps1.

Here is a annotated version of the file:

$cfg = @{} #Do not modify this line


# Informations about the source vCenter
$cfg.sourcevc = @{
    vc = ''
    user = 'administrator@vsphere.local'
    password = 'VMware1!'

# Information about the destination vCenter
$cfg.destinationvc = @{
    vc = ''
    user = 'administrator@vsphere.local'
    password = 'VMware1!'

# Cluster translation table
# List of source and destination clusters
# You can provide only one line
$cfg.cluster = @(
    @{source = 'CLUSTER01' ; destination = 'CLUSTER02'}

# List of VM matching the specified pattern and excluded VMs
# vm = '*' -> All VM selected
# vm = 'TEST*' -> All VM who's name starts with TEST
$cfg.vm = @{
    scope = '*'
    exclusion = @('VM01','VM02')


# Portgroup translation table
# List of source and destination portgroups
# If the source portgroup is not on the list, the script will look at a destination portgroup with the same name 
$cfg.portgroup = @(
    @{source = 'PORTGROUP01'; destination = 'PORTGROUP03'}
    @{source = 'PORTGROUP02'; destination = 'PORTGROUP04'}

# Datastore translation table
# List of source and destination datastores
# If the source datastore is not on the list, the script will look at a destination datastore with the same name
# If the VM has multiple datastore, the first one is selected
# Selecting a datastore cluster as destination is not supported
$cfg.datastore = @(
    @{source = 'DATASTORE01'; destination = 'DATASTORE04'}
    @{source = 'DATASTORE02'; destination = 'DATASTORE05'}
    @{source = 'DATASTORE03'; destination = 'DATASTORE06'}

To Do

  • Add possibility to select specifics VMHosts
  • Add possibility to run vMotion asynchronously
  • Add logs

Sign in to be able to add comments.

Comments 4

nnaga 2 years ago
Hi Equelin,
Thanks for this great script, just the script I was looking for. This would make my job so easy.
When I run Get-Command -Module PSxVCvMotion, I get Invoke-xVCvMotion and Move-xVCvMotion.
Whats the difference and use case between Invoke and Move.
equelin 2 years ago
Hello Naga,
Thanks for the feedback! Invoke-xVCvMotion is the command you want to use. The other one is used internally, I shouldn't have published it.
TonyHoover21 2 years ago
Good Afternoon,
I just found this Post & Love your Script!
Is it possible to put in an exclusive list of VMs instead of using selected pattern?
rahulchaudhry007 1 month ago
Hi Equelin,
I have a really complicated environment with multiple vDS's and we also use PVLANs, was trying to use this script to migrate a VM on a PVLAN to another vCenter, but I keep getting the following error.

[+] Source portgroup NetApp-stg-iso exists 2ms
[+] Destination portgroup NetApp-stg-iso exists 2ms
[-] If source portgroup is a vds, destination can't be a vss 12ms
Expected $false, but got $true.
94: ($sourcePortgroup.ExtensionData.Key -like 'dvportgroup-*') -and ($Destinationportgroup.ExtensionData.Key -notlike 'dvportgroup-*') | Should Be $False
at <ScriptBlock>, C:\Users\Admin\Documents\WindowsPowerShell\Modules\PSxVCvMotion\1.0.0\Tests\Pre.Tests.ps1: line 94

Any help would be really appreciated