1. Download and install Putty and Putty tools

You will need both Putty.exe and PLink.exe (which is what will be sending the SSH commands to your ESXi server)

I downloaded and installed from the following link to c:\putty

http://the.earth.li/~sgtatham/putty/latest/x86/putty-0.63-installer.exe

2. Enable SSH on your vSphere (ESXi) host

Within the vSphere client click on your host.

Then click on the “Configuration” tab

Then click on the “Security Profile” link

Then under Services click “Properties”

Highlight “SSH” and click “Options”

Select the “Start and stop with host” radio button and click OK

Then click OK to close the window.

SSH should now start and stop with your host.

3. Create a saved SSH session to your vSpehre/ESXi host

Open Putty.exe

type in the host name or IP address of the vSphere/ESXi server

Highlight the SSH radio button

Click in the saved sessions field and give your ESXi server a friendly short name (I called mine esxi !)

Click “Save”

Then highlight your new entry and click “Open”

Log onto your ESXi box using the root username and password you set for your host.

Close putty.

4. Create a batch file with the SSH commands necessary to shut down your host

Create a folder for your putty.exe, plink.exe files and create a batch file in that folder. You can call it whatever you like, but I called my batch file “shut.bat”. I called my folder “putty”.

So my files reside in c:\putty

In that file you will need the following lines of code (the stuff in brackets explains what they do!)

echo %date%-%time% line#1 >>c:\putty\shutstart.txt (this writes a file that tells you when the script was set off)

c:\putty\plink.exe esxi -l root -pw youresxirootpassword “/sbin/shutdown.sh && /sbin/poweroff” (where esxi is the putty saved session variable I created in step 3. This code issues the shutdown and power off commands to that ESXi host)

SHUTDOWN /S /T 5 (this shuts down the control computer – you could hibernate here with the /H flag instead of the /S)

echo %date%-%time% line#3 >>c:\putty\shutend.txt (this writes a file telling you when the script ended)

5. Create a windows scheduled task that is set off manually

This step is necessary to get IPM to invoke the batch file with the right permissions. I spent ages trying to get RunAs permissions etc working but in the end this workaround works perfectly.

1. Fire up the windows task scheduler.
2. Right click on “Task Scheduler (local) and click “Create Task”
3. Give your task a name. I called mine runshutbat
4. Tick the “Run with highest privileges” tick box
5. Click on the “Actions” tab
6. Click the “New” button
7. Make sure “Start a program” is the action selected and then browse to your shut.bat file
8. From the conditions tab untick “Start task only if computer is on AC power”
9 Save your scheduled task

6. Fire up Eaton IPM (or your control software)

This step tells IPM what to do when an “on battery” power state is experienced. We want it to fire off our scheduled task to gracefully shutdown our esxi host/s and our control PC.

1. Log into IPM
2. Browse to the “Settings ->Shutdown” view
3. Double Click on “Configuration”
4. Edit it with the settings in the attached picture (of course you can amend shutdown timer and duration for your environment).

Note: Shutdown timer is the duration that the UPS waits before doing “something” in case power is restored. Shutdown duration is the length of time you have given for whatever script/s actions to take place. At the end of the shutdown timer + duration period the UPS will switch itself off in the “Outlet shutoff active” tick box is ticked. Else it will continue to run down its battery (or charge it when power is restored)

Note 2: The shutdown script in this example is what you need to fire off the scheduled task you created in step 5. Remember to change the name “runshutbat” to whatever the scheduled task name you gave it.

7. Test it

Easiest way to test it is to pull the input feed plug from the back of the UPS. This throws the UPS into battery mode and after your Shutdown Timer duration the UPS should fire off the Scheduled task which fires off the script.