How to Power off or reboot VMWare VM from CLI

Posted by

Recently, I got to see something I haven’t had to experience in a while. I had a VM that wouldn’t power down in the GUI even after I vMotion it to another host. I had to go back into my old school archive for the procedure of bringing down a VM via CLI from the ESXi host it lives on.

Step 1.
Log into ESXi hosts that VM lives on as root

Step 2.
You need to list out all VMs and get their Vmid number
#vim-cmd vmsvc/getallvms

Step 3.
Grab the VMs Vmid from the far left side of screen
See the current state of the VM
#vim-cmd vmsvc/powergetstate vmid#

Step 4.
Power off the VM or if you are looking to reboot move to step 6.
#vim-cmd vmsvc/power.off vmid#

Step 5.
If you need to power on the VM
#vim-cmd vmsvc/power.on vmid#

Step 6.
If you need to reboot the VM use the following command
#vim-cmd vmsvc/power.reboot vmid#

Summary:
There are still times even in the VMWare 6.7 world where you may need to still use CLI to power on/off or reboot a VM. I hope y’all find this article useful.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s