Tuesday, April 14, 2015

Power ON or OFF VMs and ESXi Host from SSH

To power on a virtual machine from the command line:
List the inventory ID of the virtual machine with the command:
vim-cmd vmsvc/getallvms |grep

Note: The first column of the output shows the vmid.

Check the power state of the virtual machine with the command:
vim-cmd vmsvc/power.getstate

Power-on the virtual machine with the command:
vim-cmd vmsvc/power.on

Shutdown gracefully VMs
esxcli vm process list
esxcli vm process kill --type=soft --world-id=WorldNumber
esxcli vm process kill --type=hard --world-id=WorldNumber
esxcli vm process kill --type=force --world-id=WorldNumber

Shutdown ESX Host

vim-cmd vmsvc/getallvms
esxcli system maintenanceMode set -e true -t 0
esxcli system shutdown poweroff -d 10 -r "Shell initiated system shutdown"
esxcli system maintenanceMode set -e false -t 0

No comments: