I am putting together a script and documentation to manage extended power outages for my facility. I have a script that automatically shuts down my hardware cleanly.

I also have VMware HA configured on my cluster. Ideally when I power back up the cluster all the VMs should start powering up in the sequence outlined in the HA configuration. Which of the HA options do I need to enable for this behavior? This obviously isn't something I can test freely in production and I don't have a test environment for this kind of thing.

I was originally thinking the virtual machine startup / shutdown options listed under the individual servers would do the trick but those settings apparently are disabled when using a vCenter Server.

EDIT: I have the VMware HA Virtual Machine Options set to use the order I would like to use. If my understanding is correct the underlying issue is that the HA functions won't restart a VM that has effectively been manually shut down. I have also included the relevant function of my shutdown script.

Function VMWareServer
# This function will shut down all virtual machines and then a VMware environment.
{ param( [string]$Server, [string]$ID, [string]$Password )
Write-Host Connecting to $Server ..
Connect-VIServer $Server -User $ID -Password $Password
Write-Host Getting virtual machines... 
$ESXSRV = Get-VMHost
Foreach ($VM in ($ESXSRV | Get-VM))
    Write-Host Shut Down $VM
        If( $shutdown ) 
            $VM | Shutdown-VMGuest -Confirm:$false 
If( $shutdown )
{   # The following lines shut down the remaining VMs and shut down 
    # the VMware servers. 
    Write-Host Waiting for shutdown to complete, be patient
    sleep 30 
    $activeVMs = ($ESXSRV | Get-VM | Where { $_.PowerState -eq "poweredOn" }).Count
    Write-Host Sleepy VMs: $activeVMs
    If( $activeVMs > 0 )
        Write-Host Giving remaining VMs 90 seconds to shut down...
        sleep 90
    $ESXSRV | Foreach {Get-View $_.ID} | Foreach {$_.ShutdownHost_Task($TRUE)}
Disconnect-VIServer -Server * -Force -Confirm:$False

Did you go into the Properties (upper right corner) of Virtual Machine Startup and Shutdown and checked the Allow virtual machines to start and stop automatically with the system check box?

  • It works a little differently with an HA setup and a cluster, those settings you referred to above are machine specific. I believe most of what he needs will be in the HA configuration and rules. Say a machine vmotions, if you didn't also set it to startup there, it won't start up. – SpacemanSpiff Sep 7 '11 at 19:55
  • My understanding is that all the settings under the virtual machine startup / shutdown screen are overwritten when using the HA option; I can't really test this suggestion. Are you sure it will do what is desired? – Tim Brigham Sep 7 '11 at 20:01
  • Based upon what SpacemanSpiff pointed out, you should look through the HA settings to determine whether it has similar and/or overriding options. – user48838 Sep 7 '11 at 20:07

Due to the complexity of this issue I'm going to build out an entire virtual cluster consisting of two ESXi nodes and a vSphere Server. I don't think there is a ready answer to this question without testing. Thanks @SpacemanSpiff and @user48838.

  • Have you any updates on this? I was asking similar question but did not solved it. – John Jan 20 '12 at 11:07
  • A shutdown script as implemented or a client from your ups vendor are the only ways to go I have found. I included the relevant bit of script in my question. – Tim Brigham Jan 20 '12 at 13:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.