1 2 Previous Next 18 Replies Latest reply on Oct 9, 2019 6:56 AM by efiumana

    Move-VM between Datacenters to DatastoreCluster

    Goshin94 Novice

      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

        • 1. Re: Move-VM between Datacenters to DatastoreCluster
          LucD Guru
          User ModeratorsCommunity WarriorsvExpert

          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.

          • 2. Re: Move-VM between Datacenters to DatastoreCluster
            Goshin94 Novice

            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

            • 3. Re: Move-VM between Datacenters to DatastoreCluster
              LucD Guru
              Community WarriorsUser ModeratorsvExpert

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

              • 4. Re: Move-VM between Datacenters to DatastoreCluster
                Goshin94 Novice

                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

                • 5. Re: Move-VM between Datacenters to DatastoreCluster
                  LucD Guru
                  Community WarriorsUser ModeratorsvExpert

                  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

                  • 6. Re: Move-VM between Datacenters to DatastoreCluster
                    Goshin94 Novice
                    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.

                    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 

                    • 7. Re: Move-VM between Datacenters to DatastoreCluster
                      LucD Guru
                      vExpertCommunity WarriorsUser Moderators

                      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.

                      • 8. Re: Move-VM between Datacenters to DatastoreCluster
                        Goshin94 Novice

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

                        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.

                        • 9. Re: Move-VM between Datacenters to DatastoreCluster
                          LucD Guru
                          Community WarriorsvExpertUser Moderators

                          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?

                          • 10. Re: Move-VM between Datacenters to DatastoreCluster
                            Goshin94 Novice

                            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.

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

                            • 11. Re: Move-VM between Datacenters to DatastoreCluster
                              LucD Guru
                              User ModeratorsCommunity WarriorsvExpert

                              No problem, I hope you enjoyed your holiday

                               

                              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?

                              • 12. Re: Move-VM between Datacenters to DatastoreCluster
                                Goshin94 Novice

                                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?

                                • 13. Re: Move-VM between Datacenters to DatastoreCluster
                                  LucD Guru
                                  vExpertCommunity WarriorsUser Moderators

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

                                  • 14. Re: Move-VM between Datacenters to DatastoreCluster
                                    Goshin94 Novice

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

                                    1 2 Previous Next