MobileAllOver
Well-Known Member
Thought the following script might help some of you guys. Concept is very simple, based on pings to network device (printer / switch) that is connected to normal AC. Once power failure occurs, the pings will timeout and you can configure what to do...
Although software can typically manage 1x PC, this script can be used to shutdown as many as you like. My script includes SMS / Email notification as well...
Requirements: Scheduled task, psshutdown utility, for linux: certificate authentication
@ECHO OFF
ECHO Pinging Server ...
PING -n 2 -w 1000 192.168.130.5 |find "Reply"
IF %errorlevel%==0 GOTO NOSHUTDOWN
ECHO CHECKING EXISTING OF NEW POWER FAILURE
IF EXIST C:\Shutdown\Forced_Shutdown.txt GOTO EOF
ECHO SHUTTING DOWN IN 5 SECONDS
IF NOT EXIST C:\Shutdown\Forced_Shutdown.txt ECHO "Forced Shutdown" > C:\Shutdown\Forced_Shutdown.txt
start /wait "SMS Notification" osql -S jupiter -Q "[sp_Email_Shutdown]" -E
start "VM Server Shutdown" C:\Shutdown\plink.exe [email protected] -i C:\Shutdown\vmware.ppk "shutdown -h +2"
start "Windows Shutdowns" C:\Shutdown\psshutdown.exe @C:\Shutdown\pcs.txt -s -e u:5:20 -t 10
GOTO EOF
:NOSHUTDOWN
ECHO Online. Not shutting down...
IF EXIST C:\Shutdown\Forced_Shutdown.txt DEL C:\Shutdown\Forced_Shutdown.txt
GOTO EOF
:EOF
Although software can typically manage 1x PC, this script can be used to shutdown as many as you like. My script includes SMS / Email notification as well...
Requirements: Scheduled task, psshutdown utility, for linux: certificate authentication
@ECHO OFF
ECHO Pinging Server ...
PING -n 2 -w 1000 192.168.130.5 |find "Reply"
IF %errorlevel%==0 GOTO NOSHUTDOWN
ECHO CHECKING EXISTING OF NEW POWER FAILURE
IF EXIST C:\Shutdown\Forced_Shutdown.txt GOTO EOF
ECHO SHUTTING DOWN IN 5 SECONDS
IF NOT EXIST C:\Shutdown\Forced_Shutdown.txt ECHO "Forced Shutdown" > C:\Shutdown\Forced_Shutdown.txt
start /wait "SMS Notification" osql -S jupiter -Q "[sp_Email_Shutdown]" -E
start "VM Server Shutdown" C:\Shutdown\plink.exe [email protected] -i C:\Shutdown\vmware.ppk "shutdown -h +2"
start "Windows Shutdowns" C:\Shutdown\psshutdown.exe @C:\Shutdown\pcs.txt -s -e u:5:20 -t 10
GOTO EOF
:NOSHUTDOWN
ECHO Online. Not shutting down...
IF EXIST C:\Shutdown\Forced_Shutdown.txt DEL C:\Shutdown\Forced_Shutdown.txt
GOTO EOF
:EOF