VMware Cloud Community
Goshin94
Contributor
Contributor

Move-VM between Datacenters to DatastoreCluster

Hi Guys,

I've been given the task to migrate all of our running VMs(approx. 2000) from one datacenter to another.

As usual, I've started to test the corresponding cmdlets I'd like to use for my script, however I don't quite get the usage of Move-VM.
What I'd like to do is move the VMs to:

- a specified folder

- a specified ESXiCluster

- a specified DatastoreCluster

I would import all of these info from a .csv file.

I encountered the following errors when I tested the cmdlet:

Refering to the 6.5 PowerCLI documentation found at VMware vSphere 6.5 Documentation Library there should be a parameter called -InventoryLocation, however when I tried,my PowerCLI couldn't find this parameter.

When I specified the ESXiCluster with the parameter -Destination, I got the following error:

Get-VM -Name Test_HB1 | Move-VM -Destination TEST-ESXi-CLU -Datastore test-dsc -PortGroup $portg

Move-VM : 2019.06.24. 14:08:50 Move-VM Cannot move the specified virtual machine 'Test_HB1' to the destination DRS cluster. Turn the virtual machine On or specify a VM Host within that cluster.

Alright, I turned the VM on, then I got the following:

Get-VM -Name Test_HB1 | Move-VM -Destination TEST-ESXi-CLU -Datastore test-dsc -PortGroup $portg

Move-VM : 2019.06.24. 14:13:41 Move-VM Cannot move the specified virtual machine 'Test_HB1' to the destination cluster and datastore. The destination cluster is a DRS cluster and a destination datastore cannot be specified.

If I specify an exact ESXi host the command runs just fine.

Get-VM -Name Test_HB1 | Move-VM -Destination tst-esx-a-009 -Datastore tst-dsc -PortGroup $portg

After many failed attempts at googling the answer I couldn't find anything related to this (or maybe my googling skills failed me), so that's why I'm asking for your help to clarify what I'm doing wrong.

Some answers to the future questions which might come up:

The 2 datacenters are in 1 vCenter.

The target ESXiCluster is connected to the target DatastoreCluster.

PowerCLI version:

PowerCLI Version

----------------

   VMware PowerCLI 6.5 Release 1 build 4624819

---------------

Component Versions

---------------

   VMware Cis Core PowerCLI Component 6.5 build 4624453

   VMware VimAutomation Core PowerCLI Component 6.5 build 4624450

   VMWare ImageBuilder PowerCLI Component 6.5 build 4561891

   VMWare AutoDeploy PowerCLI Component 6.5 build 4561891

   VMware Vds PowerCLI Component 6.5 build 4624695

   VMware Cloud PowerCLI Component 6.5 build 4624821

   VMware HA PowerCLI Component 6.0 build 4525225

   VMware HorizonView PowerCLI Component 7.0.2 build 4596620

   VMware Licensing PowerCLI Component 6.5 build 4624822

   VMware PCloud PowerCLI Component 6.5 build 4624825

   VMware Storage PowerCLI Component 6.5 build 4624820

   VMware vROps PowerCLI Component 6.5 build 4624824

   VMware vSphere Update Manager PowerCLI 6.5 build 4540462

Thank you in advance for your reply,

Goshin

Reply
0 Kudos
21 Replies
dbuenoparedes
Enthusiast
Enthusiast

Same here Marcussen, seems that the Move-VM cmdlet is still not compatible with datastore cluster objects, I was able to get around this by simulating a SDRS placement just based on free space left following the instructions in https://blogs.vmware.com/PowerCLI/2017/01/spotlight-move-vm-cmdlet.html

I tried this on PowerShell core v7.0.0 and PowerCLI v12.0.0.15947286

Reply
0 Kudos
LucD
Leadership
Leadership

Out of curiosity, did you/can you also try it with PS v5.1 and PowerCLI 12.0?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos