VMware Cloud Community
JonesytheGreat
Enthusiast
Enthusiast

Schneider Electric Network Shutdown Module and Powercli

I am trying to get my vmware environment to shut down using powercli when the shutdown module receives an alert that there is a power problem.  I was lucky to find the script that I needed here http://blog.mwpreston.net/2012/08/07/practise-makes-perfect-more-powercli-apc-powerchute-network-shu... but I don't know if there is a way to get the shutdown module to use a script like this.  Is it possible to do this from a batch file instead?

Thanks in advance,

Matt

Tags (3)
0 Kudos
4 Replies
LucD
Leadership
Leadership

What exactly do you mean with "the shutdown module" ?

Is that a PowerCLI script or a CMD file ?

You can call a PowerCLI script from both in fact.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
JonesytheGreat
Enthusiast
Enthusiast

Wow, quick reply! 

I should probably elaborate a bit.  Basically my UPSs use a program from Schneider Electric called the network shutdown module http://www.apc.com/resource/include/techspec_index.cfm?base_sku=SFNSMW.  I cannot use the powerchute network shutdown because my UPSs are a little older. 

The way this will work (hopefully) is that the UPS signals a physical machine that there is a power problem and the UPS will shut down in X number of minutes.  This would kick off the script on the physical server to shutdown my VMs and then shutdown my hosts. 

I know that the shutdown module software allows for the running of a batch file, but I am a little confused if there is anything extra I need to do to get the .ps1 powercli to run as a batch file.  I don't know if you can see the line where it pulls the batch file so I attached the picture as well.

networkshutdown.jpg

0 Kudos
LucD
Leadership
Leadership

From a BAT or CMD file you can call a PowerCLI script like this.

C:\WINDOWS\system32\windowspowershell\v1.0\powershell.exe  -PSConsoleFile “C:\Program Files\VMware\Infrastructure\vSphere  PowerCLI\vim.psc1″ ” &  “C:\MyScript.ps1″

You will have to have PowerCLI installed on the machine that runs the BAT file.

Make sure that the path to the .PSC1 file is correct for the station from which you run the BAT file.

In that .PSC1 file the PowerCLI snapin is loaded.

If the BAT file runs under another account than yours, make sure the PowerShell ExecutionPolicy is set correctly.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

JonesytheGreat
Enthusiast
Enthusiast

Thanks!  I am going to test this out tonight. 

0 Kudos