Please find the below script for shutdown the Unix & Windows server remotely.
#!/bin/bash
SSH=/usr/bin/ssh
POWERCMD="/sbin/shutdown -h now"
HOSTS="server1 server2 server3"
# Shutdown remote machines
for i in $HOSTS;
do
$SSH -l root $i $POWERCMD;
done
telnet=/usr/bin/telnet
POWER="C:\Windows\System32\shutdown.exe \s"
IP="server1 server2 server3"
# Shutdown window machine
for i in $IP;
do
$telnet -l administrator $i $POWER;
done
# Shutdown ourself
/sbin/shutdown -h now
#!/bin/bash
SSH=/usr/bin/ssh
POWERCMD="/sbin/shutdown -h now"
HOSTS="server1 server2 server3"
# Shutdown remote machines
for i in $HOSTS;
do
$SSH -l root $i $POWERCMD;
done
telnet=/usr/bin/telnet
POWER="C:\Windows\System32\shutdown.exe \s"
IP="server1 server2 server3"
# Shutdown window machine
for i in $IP;
do
$telnet -l administrator $i $POWER;
done
# Shutdown ourself
/sbin/shutdown -h now