Posts Tagged /vmsvc
How to Power-Off / Shutdown Virtual Machine on VMWare ESXi5
Posted by habibalby in VMware vSphere on November 11, 2012
How to Power-Off / Shutdown Virtual Machine on VMWare ESXi5
Symptoms
You are experiencing these issues:
- You cannot power off an ESXi hosted virtual machine.
- A virtual machine is not responsive and cannot be stopped or killed.
- You cannot power off an ESXi because it’s hanged with lots of SCSI Storage I/Os
You can start by obtaining the <VMID> and you can run the power action against the VMID generated by the below command;
vim-cmd vmsvc/getallvms – list all VMs registered on the host
vim-cmd vmsvc/power.getstate <vmid> – show power state of a VM
vim-cmd vmsvc/power.shutdown <vmid> – shutdown a VM (shutdown guest)
vim-cmd vmsvc/power.reset <vmid> – reset a VM
vim-cmd vmsvc/power.off <vmid> – power off a VM
vim-cmd vmsvc/power.on <vmid> – power on a VM
vim-cmd vmsvc/power.reboot <vmid> – reboot a VM
vim-cmd vmsvc/get.summary <vmid> – get summary information for a VM
vim-cmd vmsvc/unregister <vmid> – unregister a VM from a host
Example;
# vim-cmd vmsvc/getallvms
Vmid Name File Guest OS Version Annotation
2 VM01 [vESXi5-01] VM01/VM01.vmx winLonghornGuest vmx-08
~ # vim-cmd vmsvc/power.getstat 2
Retrieved runtime info
Powered on
~ # vim-cmd vmsvc/power.shutdown 2
(vim.fault.ToolsUnavailable) {
dynamicType = <unset>,
faultCause = (vmodl.MethodFault) null,
msg = “Cannot complete operation because VMware Tools is not running in this virtual machine.”,}
In the above example, it gives me an error that cannot Shutdown the VM as the VMWare Tools is not running.
But by running the command to forcibly power off the VM with Power.Off command, it’s immediately powered off the named VM ID. (2)
~ # vim-cmd vmsvc/power.off 2
Powering off VM:
~ # vim-cmd vmsvc/power.getstat 2
Retrieved runtime info
Powered off
~ #
Commands available under vmsvc/:
~ # vim-cmd vmsvc/
Commands available under vmsvc/:
acquiremksticket get.spaceNeededForConsolidation
acquireticket get.summary
connect get.tasklist
convert.toTemplate getallvms
convert.toVm gethostconstraints
createdummyvm login
destroy logout
device.connection message
device.connusbdev power.getstate
device.disconnusbdev power.hibernate
device.diskadd power.off
device.diskaddexisting power.on
device.diskremove power.reboot
device.getdevices power.reset
device.toolsSyncSet power.shutdown
device.vmiadd power.suspend
device.vmiremove power.suspendResume
devices.createnic queryftcompat
get.capability reload
get.config setscreenres
get.config.cpuidmask snapshot.create
get.configoption snapshot.dumpoption
get.datastores snapshot.get
get.disabledmethods snapshot.remove
get.environment snapshot.removeall
get.filelayout snapshot.revert
get.filelayoutex snapshot.setoption
get.guest tools.cancelinstall
get.guestheartbeatStatus tools.install
get.managedentitystatus tools.upgrade
get.networks unregister
get.runtime upgrade
get.snapshotinfo
~ #