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
LucD
Leadership
Leadership

The InventoryLocation parameter on the Move-VM cmdlet was added in VMware PowerCLI 6.5.2.

See the ChangeLog, search for InventoryLocation.

I would strongly suggest you upgrade your PowerCLI version.


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

Reply
0 Kudos
Goshin94
Contributor
Contributor

Thanks for your reply!
As usual, I tend to overlook the simplest solutions.

This seems to have solved my previous problem(s), however now I get the following error:

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

Move-VM : 2019.06.25. 11:26:39 Move-VM A specified parameter was not correct: RelocateSpec

Reply
0 Kudos
LucD
Leadership
Leadership

Did you upgrade your PowerCLI version?
Which PowerCLI version are you using now?


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

Reply
0 Kudos
Goshin94
Contributor
Contributor

Yes, I did with the following command:

Install-Module -Name VMware.PowerCLI -Scope CurrentUser -Force

Current PowerCLI version:

Get-PowerCLIVersion

PowerCLI Version

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

   VMware PowerCLI 11.3.0 build 13990089

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

Component Versions

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

   VMware Cis Core PowerCLI Component PowerCLI Component 11.3 build 13964830

   VMware VimAutomation VICore Commands PowerCLI Component PowerCLI Component 11.3 build 13964826

   VMWare ImageBuilder PowerCLI Component 6.7 build 11233116

   VMWare AutoDeploy PowerCLI Component 6.7 build 11233116

   VMware VimAutomation Vds Commands PowerCLI Component PowerCLI Component 11.2 build 12483615

   VMware VimAutomation Cloud PowerCLI Component PowerCLI Component 11.0 build 10379994

   VMware HorizonView PowerCLI Component 7.1.0 build 13827661

   VMware VimAutomation License PowerCLI Component PowerCLI Component 11.3 build 13990093

   VMware VimAutomation Storage PowerCLI Component PowerCLI Component 11.3 build 13976676

   VMware VimAutomation vROps PowerCLI Component PowerCLI Component 10.0 build 7893921

   VMware vSphere Update Manager PowerCLI 6.5 build 7862888

   VMware HA PowerCLI Component 6.0 build 4525225

   VMware PCloud PowerCLI Component 6.5 build 4624825

Reply
0 Kudos
LucD
Leadership
Leadership

Your previous version was 6.5R1, which is an EXE install if I'm not mistaken.

Did you remove that completely before installing the latest version with Install-Module?

Instructions for the removal can be found in Welcome PowerCLI to the PowerShell Gallery – Install Process Updates

I'm afraid you're now running a mix of 6.5R1 and 11.3.0.
Best would be to

  1. Uninstall the old 6.5R1 (see instructions in link above)
  2. Remove all PowerCLI folders manually. You can find out which folders to look in by

Get-Module -Name VMware.* -ListAvailable | select Name,ModuleBase

Remove the complete folder, i.e. above the version number
For C:\Program Files\WindowsPowerShell\Modules\VMware.VimAutomation.Core\11.3.0.13964826
remove folder C:\Program Files\WindowsPowerShell\Modules\VMware.VimAutomation.Core

When done check with

Get-Module -Name VMware.* -ListAvailable | Select Name,Version


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

Reply
0 Kudos
Goshin94
Contributor
Contributor

Your previous version was 6.5R1, which is an EXE install if I'm not mistaken.

Yup, it was.

Done the steps, but the problem still persists with the same error message. Smiley Sad

Get-Module -Name VMware.* -ListAvailable | Select Name,Version

Name                                Version       

----                                -------       

VMware.DeployAutomation             6.7.0.11233116

VMware.ImageBuilder                 6.7.0.11233116

VMware.PowerCLI                     11.3.0.13990089

VMware.Vim                          6.7.0.13964812

VMware.VimAutomation.Cis.Core       11.3.0.13964830

VMware.VimAutomation.Cloud          11.0.0.10379994

VMware.VimAutomation.Common         11.3.0.13964816

VMware.VimAutomation.Core           11.3.0.13964826

VMware.VimAutomation.Hcx            11.3.0.13976786

VMware.VimAutomation.HorizonView    7.6.0.13827661

VMware.VimAutomation.License        11.3.0.13990093

VMware.VimAutomation.Nsxt           11.3.0.13964817

VMware.VimAutomation.Sdk            11.3.0.13964823

VMware.VimAutomation.Security       11.0.0.10380515

VMware.VimAutomation.Srm            11.2.0.12483605

VMware.VimAutomation.Storage        11.3.0.13976676

VMware.VimAutomation.StorageUtility 1.3.0.0       

VMware.VimAutomation.Vds            11.2.0.12483615

VMware.VimAutomation.Vmc            11.3.0.13964814

VMware.VimAutomation.vROps          10.0.0.7893921

VMware.VumAutomation                6.5.1.7862888 

Reply
0 Kudos
LucD
Leadership
Leadership

I can't seem to be able to replicate that error.
Can you provide some more info on the environment?
Where is that VM currently located? Same cluster, same ESXi node, same datastore...?

Is the target datastore accessible from the current ESXi node?

You could also try to capture the error with the Get-ErrorReport cmdlet.
See Improving PowerCLI Support with Get-ErrorReport for details on how to do that.
The resulting archive might contain some further pointers to the cause of the problem.


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

Reply
0 Kudos
Goshin94
Contributor
Contributor

Our environment looks like this (I've changed the names, since this a Production environment)

pastedImage_0.png

The VM is currently in the TST-CLU02-B ESXiCluster, in the Script_TestHB-B folder and on the test-dsc-b DatastoreCluster.

The target should be the TST-CLU02-A ESXiCluster, Script_TestHB-A folder and the test-dsc-a DatastoreCluster.

Is the target datastore accessible from the current ESXi node?

No, it's not. TST-CLU02-B ESXiCluster can only see the test-dsc-b DatastoreCluster and the TST-CLU02-A ESXiCluster can only see the test-dsc-a DatastorCluster.

But this shouldn't be a problem, right? I could easily do the migation with the webclient.

So to reflect the information above, my command should look like this:

Get-VM -Name Test_HB1 | Move-VM -Destination TST-CLU02-A -Datastore test-dsc-a -PortGroup $portg -InventoryLocation Script_TestHB-A

Using the Get-ErrorReport cmdlet, I generated a report and I got the same

GetResponse -The remote server returned an error:(500) Internal Server Error

error as in the article you provided.

Hope this somehow helps.

Reply
0 Kudos
LucD
Leadership
Leadership

The error report is an archive, in there are multiple files.
Extract the files and first have a look at the .txt files.
Anything in there that might shed a light?

The .svc file is a trace file, and requires you to have the tool Kyle mentioned in the blog.
How big is that file?


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

Reply
0 Kudos
Goshin94
Contributor
Contributor

I checked all of the .txt files, but nothing useful, just the same error message I got on the PowerShell Console.
I opened the .svc file with the same tool as in the blog, the file is roughly ~800 MB.

pastedImage_0.png

(Sorry for the kinda late reply, I was on holiday.)

Reply
0 Kudos
LucD
Leadership
Leadership

No problem, I hope you enjoyed your holiday Smiley Happy

The value you pass on the Datastore parameter, is that a DSC name?
If yes, did you already try by giving a single datastore instead of a DSC?


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

Reply
0 Kudos
Goshin94
Contributor
Contributor

The value you pass on the Datastore parameter, is that a DSC name?

If yes, did you already try by giving a single datastore instead of a DSC?

Yes, it's a DSC.
With a single datastore as a target, it runs just fine.

Looks like I have to settle with this option?

Reply
0 Kudos
LucD
Leadership
Leadership

Is DRS for that DSC on and set to "Fully Automated"?


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

Reply
0 Kudos
Goshin94
Contributor
Contributor

It's ON, but it's set to "No Automation".

Reply
0 Kudos
Goshin94
Contributor
Contributor

Same Error with DRS set to "Fully Automated"

Reply
0 Kudos
LucD
Leadership
Leadership

Then I think you better open a SR


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

Goshin94
Contributor
Contributor

Alright, thank you.
I will reply the answers if I get/find any.

Reply
0 Kudos
efiumana
Enthusiast
Enthusiast

Hi Goshin,

i have the esame problem here

Have u solved it in some way?

Thank!

   Enrico

Reply
0 Kudos
Marcussen
Contributor
Contributor

Hi,

I'm having the exact same issue. Trying to move to new cluster and new DSC. PowerCLI 11.5.0 and getting the same error .

Have any of you found a solution yet?

Thanks

- Thomas

Reply
0 Kudos