Created
August 14, 2016 22:36
-
-
Save jauderho/4e2d771d5f3154fbd63552513d601ad3 to your computer and use it in GitHub Desktop.
VMware ESX - Resume all VMs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#/bin/sh | |
VMS=`vim-cmd vmsvc/getallvms | grep vmx | awk '{print $1}'` | |
for VM in $VMS ; do | |
PWR=`vim-cmd vmsvc/power.getstate $VM | grep -v "Retrieved runtime info"` | |
if [ "$PWR" == "Suspended" ] ; then | |
name=`vim-cmd vmsvc/get.config $VM | grep -i "name =" | awk '{print $3}' | head -1 | cut -d "\"" -f2` | |
echo "Suspended: $name" | |
echo "Resuming: $name" | |
vim-cmd vmsvc/power.on $VM > /dev/null & | |
fi | |
done | |
while true ; do | |
RUNNING=0 | |
for VM in $VMS ; do PWR=`vim-cmd vmsvc/power.getstate $VM | grep -v "Retrieved runtime info"` | |
if [ "$PWR" == "Suspended" ] ; then | |
echo "Waiting..." | |
RUNNING=1 | |
fi | |
done | |
if [ $RUNNING -eq 0 ] ; then | |
echo "Done..." | |
break | |
fi | |
sleep 1 | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment