Run the below Script in vSphere Command line.
#!/bin/bash
######### AUTHOR : Srinivasan ##############
######### Date : 13.04.2015 ################
######### Purpose: To startup the VM(s) in the Vsphere Esxi Host ##########
echo "$(/sbin/vim-cmd vmsvc/getallvms)"
echo -n "Enter the VM ID to startup:"
read VM_ID
VM_STATE=$(/sbin/vim-cmd vmsvc/get.summary $VM_ID | grep powerState | cut -d '=' -f 2 | sed -e 's/,//g' -e 's/"//g')
if [ $VM_STATE = "poweredOff" ]; then
echo "Going to Startup VM with id $VM"
/sbin/vim-cmd vmsvc/power.on $VM_ID
else
echo "Given VM_ID is already PoweredOn"
fi
No comments:
Post a Comment