3 Replies Latest reply on May 8, 2013 5:33 AM by LucD

    Script HA migration?

    FJ1200 Enthusiast

      Fairly new to Powershell and CLi but not to scripting - is it possible to script HA so that it restarts VMs on specific hosts?  Unfortunately the cost of 10 Enterprise ESXi 5.x licenses is prohibitive just for DRS and Accessibility Control won't do what we want.  I really want the affinity and anti-affinity rules.  Really, Really badly!

        • 1. Re: Script HA migration?
          LucD Guru
          User ModeratorsvExpertCommunity Warriors

          Everything is possible in PowerCLI


          For a simple simulation of affinity/anti-affinity rules, you should do all start/stop of VMs through a script.

          In that script you can test on which ESXi a VM can be started, talking into account the rules you would have in a file somewhere.


          A tentative start VM logic

          • read all rules
          • get the VM that needs to be started
          • is there a rule that includes this VM
            • affinity: check where the affine VM(s) are running -> that will be the target ESXi
            • anti-affinity
              • get all available ESXi hosts
              • remove the ESXi that have VMs from the anti-affinity rule running
              • select an ESXi host from the remaining ones


          That should be quite simple to code in PowerCLI.

          But remember that this is a very crude simulation fo what HA offers.

          1 person found this helpful
          • 2. Re: Script HA migration?
            FJ1200 Enthusiast

            Thanks Luc.  It's just the migration to other hosts I'm looking at not restarting the VM on it's normally homed host.  Don't really have lots of time but I'll have a play with it and see how it goes.  Can't do the resource checking either.


            I with they'd put DRS on the Standard license. 

            • 3. Re: Script HA migration?
              LucD Guru
              Community WarriorsUser ModeratorsvExpert

              Ok, I see.

              In that case you could still use the external file with the rules, and then eventually use the Move-VM cmdlet to vMotion the VM to the correct ESXi host.