Next you need to allow unsigned scripts to do this:
C:\powershell.exe set-ExecutionPolicy unrestricted
To verify you can view the setting
Install your UPS and configure your power settings then modify your initial alert to run a batch file at 50% battery life:
Here is an example batch file “PowerAlertEmail.bat”
Here is an example “PowerAlertEmail.ps1” Script
## Define the variables for smtp server, from address, to address, subject and message body
$emailFrom = email@example.com
$emailTo = firstname.lastname@example.org
$subject = "ALERT – Building 1 Possible Power Outage Onsite Batteries < 50%" $body = "Power Outage- Battery Backups Below 50% reconnect power immediately or servers will be shut down shortly"
$smtpServer = "192.168.1.10"
## Initiate sending a message to the IT group.
Then setup your UPS to run the PowerAlertEmail.bat when the battery reaches <50%
Shared Credit: Tim Lewis