How to Power Off a Virtual Machine in VMware vSphere
Multiple methods to gracefully or forcefully power off a VM using vSphere Client, esxcli, esxtop, or vim-cmd.
Powering Off a Virtual Machine Using vSphere Client/vSphere Web Client
- Connect the vSphere Client or vSphere Web Client to VMware vCenter Server.
- Right-click the virtual machine and click Power off.
- If the power operation fails with Another task is already in progress, wait for the task to complete or see Powering off a virtual machine fails with the error: Cannot power Off: Another task is already in progress (1027040) or vCenter operation times out with the error: Operation failed since another task is in progress (1004790).
- If the virtual machine remains running, attempt the same operation directly from the ESXi host:
- Connect the vSphere Client or VMware Host Client directly to the ESXi host running the virtual machine.
- Right-click the virtual machine and select Power off.
Note: From vSphere 6.5, you can enable Virtual Machine Encryption to protect virtual machine and its files. If encryption is enabled, you must have a set of Cryptographic Operations privileges; otherwise, you will not be able to power off the virtual machine. For more information, see Prerequisites and Required Privileges for Encryption Tasks in the ESXi and vCenter Server 6.5 Documentation.
If the virtual machine cannot be powered off gracefully using the client, use one of the command-line options below.
Using ESXi esxcli Command to Power Off a Virtual Machine
The esxcli command can be used locally or remotely to power off a virtual machine running on ESXi 5.x or later.
-
Get a list of running virtual machines, identified by World ID, UUID, Display Name, and path to the
.vmxconfiguration file:esxcli vm process list -
Power off the virtual machine from the list using:
esxcli vm process kill --type=[soft,hard,force] --world-id=WorldNumberNotes:
- Three power-off methods are available:
softis the most gracefulhardperforms an immediate shutdownforceshould be used as a last resort
- Three power-off methods are available:
-
Repeat Step 2 and validate that the virtual machine is no longer running.
Using esxtop to Kill a Virtual Machine
You can use the k command in esxtop to send a signal to, and kill, a running virtual machine process.
-
On the ESXi console, enter Tech Support mode and log in as root.
-
Run the
esxtoputility:esxtop -
Press c to switch to the CPU resource utilization screen.
-
Press Shift+v to limit the view to virtual machines (makes it easier to find the Leader World ID in step 7).
-
Press f to display the list of fields.
-
Press c to add the column for the Leader World ID.
-
Identify the target virtual machine by its Name and Leader World ID (LWID).
-
Press k.
-
At the World to kill prompt, type the Leader World ID from step 7 and press Enter.
-
Wait 30 seconds and validate that the process is no longer listed.
Using vim-cmd to Power Off the Virtual Machine
-
On the ESXi console, enter Tech Support mode and log in as root.
-
Get a list of all registered virtual machines, identified by their VMID, Display Name, and path to the
.vmxconfiguration file:vim-cmd vmsvc/getallvms -
Get the current state of a virtual machine:
vim-cmd vmsvc/power.getstate VMID -
Shutdown the virtual machine using the VMID found in Step 2:
vim-cmd vmsvc/power.shutdown VMIDNote: If the virtual machine fails to shut down, run:
vim-cmd vmsvc/power.off VMID
Additional Notes
If the above procedures did not resolve the issue and the ESXi host is responsive, you may need to reboot the host to put the virtual machine in a powered-off state. To avoid downtime, you can migrate all virtual machines to other ESXi hosts using vMotion.