My home lab is a single workstation that runs the free version of ESXi. I don’t really have much of a need for more then that so I don’t want to go spending large amounts of money on licences etc that I really am not going to make good use of.

So today after we had a power outage at my place for a few hours I realised that while having a cheap and nasty lab is OK. I need a way to cleanly shut it all down so that I don’t get corruption in my VMs from just powering them off. (This happened).

So I went about searching for a free way to shut-down my VMWare host at minimal or no cost to myself using my sub $100 Cyberpower UPS.

  • First step was to download and install VMWare vSphere PowerCLI from my.vmware. This can be found at
  • Second step was to download and install Power Panel which would allow me to communicate with my UPS. (You can use any software as long as it will allow you to execute a batch script at particular events or timers.
  • On the VMWare host perform the following configuration change. (This will tell the host to perform a clean shutdown rather then just cutting the power to the machines)
    • Host
    • Configuration Tab
    • Virtual Machine Start up/Shut down
    • Select properties and make the following changes
      • Check “Allow virtual machines to start and stop automatically with the system”
      • Default Start up Delay – 15 seconds
      • Default Shut down Delay – 15 seconds
      • Shut down Action: Guest Shut down
  • Install VMWare tools (or equivalent) onto all guest machines.

After that was all set-up I created a batch script (As power panel wont allow me to execute a Power shell script) with the following contents

C:\WINDOWS\system32\windowspowershell\v1.0\powershell.exe "C:\Scripts\shutdown-vm.ps1"

All that script does is tell the system to execute my power shell script using the power shell executable

Next onto the Power shell Script

#Load the VMWare PowerCLI Requirements
add-pssnapin VMware.VimAutomation.Core

#Connect to the VMWare Server - Supplying a username and password
Connect-VIServer -Server -user root -pass "password"

##Get a list of hosts on the server and perform a shutdown on them 
Get-VMHost -server | Stop-VMHost -Force -Confirm:$false

Save it as C:\Scripts\shutdown-vm.ps1 and then schedule it to run once the power is out for a few minutes.

And there you have it, a shut down script that will allow you to shut down you ESXi Free host.