3.14.2013

Remotely Power On / Power Off a VM in VMware ESXi via SSH

Remotely Power On / Power Off a VM in VMware ESXi via SSH


ESXi 4 -


vim-cmd vmsvc/getallvms - this command checks for your existing VMs, then run

vim-cmd vmsvc/power.off 48 - <vm id> on my ESXi is 48.

If you need to restart your VM on a daily basis I would edit and add the cron job in:

var/spool/cron/crontabs/root

Command for restarting any vm is:

vim-cmd vmsvc/power.restart <vm-id



1. Use grep to find the ID of your VM (1008 in this example):
~ # vim-cmd vmsvc/getallvms | grep -i CENTOS1
1008   CENTOS1      [CX4-01-LUN9] CENTOS1/CENTOS1.vmx         centos64Guest
2. Quick sanity check to verify the VM is actually powered off:
~ # vim-cmd vmsvc/get.summary 1008 | egrep '(power|ip)'
      powerState = "poweredOff",
      ipAddress = ,
3. Power on, wait a few moments, and check status again:
~ # vim-cmd vmsvc/power.on 1008
Powering on VM:
~ # vim-cmd vmsvc/get.summary 1008 | egrep '(power|ip)'
      powerState = "poweredOn",
      ipAddress = "10.136.234.38",
~ #
4.  Connect with ssh (or RDP, if targeting a Windows VM) and get on with things

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.