Power off a virtual machine in an ESXi host using the command line

1. SSH into your ESXi server
2. Get a list of all registered virtual machines, identified by their VMID, Display Name and path to the .vmx configuration file
vim-cmd vmsvc/getallvms
vim-cmd vmsvc/getallvms

3. Get the current state of a virtual machine by running this command:
vim-cmd vmsvc/power.getstate 13
vim-cmd vmsvc/power.getstate 13

4. Shutdown the virtual machine using the VMID found in Step 2 and run this command:
im-cmd vmsvc/power.shutdown 13
vim-cmd vmsvc/power.shutdown 13

5. If the virtual machine fails to shut down, run this command:
vim-cmd vmsvc/power.off 13
vim-cmd vmsvc/power.off 13