Shutdown ESXi host over SSH

  1. Connect ESXi host over SSH
  2. Get a list of running virtual machines, we will use the [World ID] later.
1
esxcli vm process list
  1. Power off the virtual machines one by one from the list
1
esxcli vm process kill --type=[soft, hard, force] --world-id=[World ID]
  1. Shutdown VMs and Power off ESXi Host
1
/sbin/shutdown.sh && /sbin/poweroff

[Alternative]Power off/on a virtual machine with command-line utilities

  1. List VMs
1
vim-cmd vmsvc/getallvms
  1. Get the power state of a VM
1
vim-cmd vmsvc/power.getstate <Vmid>
  1. Power on a virtual machine
1
vim-cmd vmsvc/power.off <Vmid>

References