PowerCLI – vMotion VM between clusters

Thanks to my college Sebastian, here his linkedin profile , I have an opportunity to post very nice PowerCLI script. Script do vMotion VM between clusters \ vDS switches and storage.

What script does:

  1. Import list of the virtual machines to migrate
  2. reconfigure VM to use standard switch
  3. migrate VM to new cluster
  4. reconfigure VM to use new vDS switch and portgroup on new cluster

[box type=”info”]

  • variable $vCenter is not needed when you work only with one vCenter server
  • clusters belongs to different virtual distributed switches
  • storage between clusters isn’t shared

[/box]

 

Artur Krzywdzinski

Artur is Consulting Architect at Nutanix. He has been using, designing and deploying VMware based solutions since 2005 and Microsoft since 2012. He specialize in designing and implementing private and hybrid cloud solution based on VMware and Microsoft software stacks, datacenter migrations and transformation, disaster avoidance. Artur holds VMware Certified Design Expert certification (VCDX #077).

  • Rostislav Soukup

    Hi Artur,
    can I use your script to vmotion VMs between 2 vcenters using vDS? When I tried to
    migrate VM, powershell says that move-vm is supported only on one VI-Server.

    I will explain my situation: due to several upgrades, my vCenter db performs bad, so I
    decided
    to start almost from scratch.I have deployed a new vCenter, now I am
    trying copy VI structures (vm folders, roles, etc..) and than migrate VMs –
    they are using vDS

    Rostislav

    • Hi,

      Is new vCenter server the same version and build as the old one ? If not, make sure that ESXi build is supported on new vCenter server.

      No chance to do it, vMotion between vCenters andor vDS is not supported. If you have to migrate VM’s between vCenter servers and you have vDS switch configured then you have more complicated way to migrate all machines to new vCenter.
      This is how I see it:
      1. Migrate vDS to vSS on old vCenter server
      2. Disconnect ESXi host (with running VM on it) from old vCenter server
      3. Connect ESXi host to new vCenter server
      4. Repeat step 2 and 3 for every server which is connected to old vCenter
      5. Migrated networking from vSS to vDS on new vCenter server

      if you have any questions feel free to ask
      good luck
      Artur

      • Rostislav Soukup

        Hi Artur,
        hmm that’s pitty. I already see some similar steps on other blogs, and hope to accomplish this other easier way. It represents lot of work – we have a lot of dvPortgroups in different zones and vDS.
        By the way old vCenter have 5.1 version, and I would like to migrate to the latest 5.5.1a.
        Does anyone skripted that painfull way?

        many thanks
        Rostislav

        • make sure your hypervisor version and hardware in on the compatibility matrix for vSphere 5.5 before you proceed.
          Not sure if anyone scripted, you will have to google it.