March 11, 2014

Can’t Power Off Virtual Machine: Operation Cannot Be Performed In Current State

If you are having trouble powering off a VMware ESXi 5.x virtual machine, there is a command line method to force the VM to shut down. Here was the message I was receiving when trying to power off a VM:

The attempted operation cannot be performed in the current state.

So the current state, which happens to be “Powered On” isn’t sufficient to power it off? Good one VMware! At least you have a sense of humor, but your error message is not helpful. But here is a command that is helpful:

esxcli vm process kill --type=[soft,hard,force] --world-id=WorldNumber

Ah, we not only get to shut down this bugger, we get to kill it! But first, let’s understand this command. The type switch can be configured for soft, which according to VMware is the “most graceful.” Or you can specify hard, which is an immediate shut down. And last we have force, which VMware says, “should be used as a last resort.” I have no idea what the specific differences are beyond these limited explanations. For my purposes, since this VM was brand new (just deployed from a template) and not in production, I simply chose “force” for expediency.

Okay, but right about now you are asking, “What the hell is the WorldNumber?” This is how you specify which VM server to kill. To find the WorldNumber, use this command:

esxcli vm process list

Now you are ready to kill your virtual machine!

Oh, and if you need anymore information, or if you are running ESXi 4.x, check out “Powering off a virtual machine on an ESXi host (1014165).”

Please share your thoughts