How to trigger a PowerShell script using PowerChute Network Shutdown?

Would like PowerChute Network Shutdown to trigger a Windows executable.

PowerChute Network Shutdown

All supported Windows OS running PowerChute Network Shutdown version 4.4.x and above


To run a Windows PowerShell script from PowerChute you must create two scripts. One is a .bat or .cmd file, and the other is a PowerShell script .ps1. We recommend using Notepad ++ to avoid Notepad or Wordpad saving the files as .txt.

PowerChute will run a .bat, so we created Trigger.bat. That file consists of
"%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe" -ExecutionPolicy Unrestricted -NoProfile -NonInteractive C:"\Temp\MyPowerShellScript.ps1"

You will need to verify or change the path to powershell.exe and change the path to the MyPowerShellScript.ps1. Also, all command files and script PowerChute Network Shutdown 4.4.x will run must be stored in

C:\Program Files\APC\PowerChute\user_files for Windows systems

/opt/APC/PowerChute/user_files/ for Linux systems

The second file is the .ps1 file. In the example below we had PowerShell trigger my.exe

Start-Process "C:\Program Files\my.exe"

You will need to verify or change the path to the .exe

The command file runs using the local system account. PowerChute cannot execute programs that require interaction with the desktop; only command line enabled programs are supported e.g. if you try to launch Notepad it will fail. In earlier versions of Windows all services run in Session 0 along with applications. This situation poses a security risk. In Windows Vista, and later versions of Windows, the operating system isolates services in Session 0 and runs applications in other sessions. PowerChute is run in Session 0 so if a command file launches a .exe that .exe will be launched in Session 0 and not visible to the logged in users. To verify that the .exe has launched open Task Manager and review the list of Processes running. More information on Windows Session can be found at http://blogs.technet.com/b/askperf/archive/2007/04/27/application-compatibility-session-0-isolation.aspx