If you are on a budget and running VMware ESXi without paying for VMware license and are looking for safe way to shutdown VMs during a power failure then look no further. We have found a way to safely suspend all VM’s running on an ESXi host in the case of a power failure using APC’s Powerchute Business Edition software. Below you will find instructions on how to configure this for your ESXi host.
Step 1: Create a shutdown script with the following contents and put it in the root of the datastore.
#!/bin/shIf you want to shutdown multiple VMs create separate lines with each VMid. In order to find the VMids SSH into the ESXi host and run the command
/bin/vim-cmd vmsvc/power.suspend VMid
vim-cmd vmsvc/getallvms. A list will be shown with each VM and its corresponding VMid.
Step 2: Open the vSphere client and select the Windows Server you want to use. Select edit settings. Select Serial Port 1 and under connection select use physical serial port and select the correct serial port from the drop down menu.
Step 3: On the Windows Server download Plink. Create a directory C:\plink. Move the .exe into the directory.
Step 4: The command files for APC are stored in C:\Program Files (x86)\APC\Powerchute Business Edition\agent\cmdfiles. In that directory create a .bat script with the following contents.
cd c:\plink This script uses plink to ssh into the ESXi host and run the script created in step 1. The APC software works better with command files that are one line and in .cmd format so create a kickoff.cmd script in the same directory to run the .bat script.
plink hostname -ssh -l root -pw password nohup sh path to the shutdown script on the datastore
Step 5: Login to the APC software. Select the Windows Server then select Server Shutdown followed by Shutdown Sequence followed by Configure Shutdown Sequence. Select command file then select kickoff.cmd from the drop down menu and select Next.
Step 6: Configure the desired shutdown sequence and select Next.
Step 7: Review to make sure everything is configured properly and select Finish.
Once configured you now have a safe way to suspend all VMs running on your ESXi host in the case of a power failure.