Managing HCX Migration via Powershell

HCX supports 3 methods for migrating VM’s to cloud:

  • Cold Migration
  • HCX Cross-Cloud vMotion
  • HCX Bulk Migration

To know more about these migration methods, please read this post  to know more about the migration methods. 

HCX migrations can be scheduled from the HCX UI using the vSphere Client or can be automated using the HCX API. In last post of this series, I demonstrated few PowerCli commands that we can use for HCX system. 

API/PowerCli is obvious choice when you think of automation. Using automation do not only help in reducing the amount of user input required in UI but reduces the chances of human errors as well.

In this post I will show use of HCX PowerCli cmdlets which you can use to automate HCX migration.

The cmdlet New-HCXMigration creates an HCX (Hybrid Cloud Extension) migration request. 

Step 1: First we have to identify the parameters which we need to pass with the cmdlet.

Run command “get-help New-HCXMigration -detailed” to obtain necessary parameters

Step 2: Next is to see how to pass these parameters in the migration cmdlet.

Run command “get-help New-HCXMigration -examples” to see full syntax of the command.

Step 3: Define necessary variables: Next is to create some variables which can be passed along with the parameters. For some strange reasons parameters were not accepting the value as such.

For example: If I pass parameter -SourceSite and pass the value mgmt01vc01 (my source site), command was failing for me.

I created following parameters in my case:

Step 4: Connect to source site HCX server. 

Step 5: Submit new migration request

Monitoring Migration

Once the migration is initiated, you can progress the migration status by running command “Get-HCXMigration“. This command will provide you with an ID associated with particular migration. 

Once the switch over completes and VM is migrated to cloud, migration status changes to “Migrated”

You can fetch detail of a specific migration by passing parameter “Id” to the Get-HCXMigration cmdlet

To see complete list of parameters that can be passed with Get-HCXMigration cmdlet, run command “get-help Get-HCXMigration -detailed

And that’s it for this post. 

I hope you enjoyed reading this post. Feel free to share this on social media if it is worth sharing :)