2 Replies Latest reply on Aug 9, 2017 2:08 PM by mars0077

    PowerCLI script for migrating VMs from one ESX cluster using VSS to another using VDS.

    mars0077 Novice

      Hi guys,

       

      I'm hoping you guys can help me out on this one. We are looking to migrate a fair amount of virtual machines from one ESX cluster using a different SAN to another ESX cluster using a new SAN. Both of these clusters are managed by the same vCenter instance.  Cluster A is using a VDS and cluster B is using VSS and we would like to go from Cluster A to Cluster B.

       

      I can easily perform this task by using the web client and performing a compute and storage migration. Using the web client also allows me to change the mapping of the source network (VSS) to the new destination network (DVS) without any errors or downtime. All preliminary compatibility checks pass with no errors.

       

      Obviously I would like to automate this process but I am running into an error when using my script.  I manually connect to my vCenter instance hence no connection string is present. All virtual machines to be moved are stored inside the vms.txt file which is being read.

       

      Here's the script:

       

      $vms = Get-Content D:\Scripts\vms.txt

       

      foreach ($vm in $vms)

      {

      #Move-VM -VM $vms -Destination 'oldesx' -Datastore 'newVMFS' -PortGroup 'newPG(VDS)'

      }

       

      Here's the error I am getting when I execute my script:

       

      Move-VM : Cannot bind parameter 'PortGroup'. Cannot convert the "myvdsportgroup" value of type "System.String" to type

      "VMware.VimAutomation.ViCore.Types.V1.Host.Networking.VirtualPortGroupBase".

      At D:\Scripts\Global\vMotion\bulkmove.ps1:6 char:114

      + ... e 'newVMFS' -PortGroup ''myvdsportgroup"

      +                                                 ~~~~~~~~~~~~~~~~~~~~~~~~~

          + CategoryInfo          : InvalidArgument: (:) [Move-VM], ParameterBindingException

          + FullyQualifiedErrorId : CannotConvertArgumentNoMessage,VMware.VimAutomation.ViCore.Cmdlets.Commands.MoveVM

       

      What do I need to include into my script to honor the portgroup change as part of the migration effort.

       

      Thanks!