Skip to content

Instantly share code, notes, and snippets.

View XianFeiXia's full-sized avatar

Olga Christiana XianFeiXia

View GitHub Profile
#!/bin/sh
VMS=`vim-cmd vmsvc/getallvms | grep -v Vmid | awk '{print $1}'`
for VM in $VMS ; do
# echo "Probing VM with id: $VM."
PWR=`vim-cmd vmsvc/power.getstate $VM | grep -v "Retrieved runtime info"`
name=`vim-cmd vmsvc/get.config $VM | grep -i "name =" | awk '{print $3}' | head -1 | awk -F'"' '{print $2}'`
echo "VM with id $VM has power state $PWR (name = $name)."
done