To automate HCX VM migration using PowerShell, you can use VMware PowerCLI cmdlets.
Install VMware PowerCLI: Ensure you have VMware PowerCLI installed on your machine.
You can download and install it from the official VMware website.
Connect to HCX: Use the following command to connect to your HCX server:
Connect-HCXServer -Server <HCX_Server_Name> -User <Username> -Password <Password>
Define Variables: Define the necessary variables for the source and destination sites, VMs, and networks:
New-HCXMigration -SourceSite $HCXSRC -DestinationSite $HCXDEST -Folder $HCXCTR -TargetComputeContainer $COMPCTR -NetworkMapping $TargetNW -TargetDatastore $TargetDS -VM $VM -ScheduleStartTime '03/08/2019 06:36:00 AM' -ScheduleEndTime '03/18/2019 07:36:00' -MigrationType Bulk