How to Stop/Kill a Stuck Virtual Machine on Hyper-V | zamarax.com (2024)

If your virtual machine running on Hyper-V is stuck for some reason, stopped responding and doesn’t start/stop/reset after clicking the corresponding buttons in the Hyper-V console, the only way out to fix this is to forcibly kill the process responsible for this VM on the host OS. I’ll show you how to force restart stuck Hyper-V VMs running on Windows Server 2016/2019 without rebooting the entire host and all running VMs (if you do not have a Hyper-V HA cluster andLive-Migration).

Hyper-V VM Stuck in the “Stopping/Starting” State

Suppose, that one of your Hyper-V VMs is stuck in theStopping(Stopping-Critical) orStarting(Starting x%) state.

The guest OS doesn’t respond and “Turn Off”, “Shut Down” and “Reset” buttons in the Hyper-V Manager either are unavailable, or return the following error when pressed:The application encountered an error while attempting to change the state of VM.
Failed to change state.
The operation cannot be performed while the object is in its current state.

Hyper-V Manager Stuck on “Connecting to Virtual Machine Management Service”

If your Hyper-V does not show virtual machines in the Hyper-V Manager console, and returns the “Connecting to Virtual Machine Management service” error, you need to restart thevmms.exe(Hyper-V Virtual Machine Management service) process. This is a safe operation and will not interrupt the running VMs. The easiest way to restart the vmms.exe process is through the vmms service using the services.msc console or with thePowerShell service management cmdlets:

Get-Service vmms | Restart-Service

How to Kill a Hung VM Process in Task Manager?

The only way to force shutdown restart such a stuck VM without rebooting the whole Hyper-V host is to end its running workflow in the guest OS. All VMs on the Hyper-V host are started using thevmwp.exeprocess (Virtual Machine Worker Process). To search for a process, you need to find out the GUID of the virtual machine.

You can get the VM GUID through theHyper-VManagerconsole. Open theHyper-V server settings. In the Server section, the location of the VM configuration files is shown (in our case it is D:VMStore).

Open this directory in File Explorer and find the folder with the same name as your virtual machine has. Copy the GUID that is specified in the name of the VM configuration file with the *.vmcx extension.

Run theTaskManagerand go to theDetailstab. All virtual machines are running in their own instance ofvmwp.exe. To determine which process is responsible for your VM, you need the GUID of the hung-up VM you obtained earlier. Locate the process vmwp.exe that has the GUID of your VM in theUsernamecolumn. Kill this process (End Task).

The virtual machine will be forced to stop. Now you can do anything with it.

Killing a Frozen Hyper-VM using PowerShell

It is much easier to find and kill the process of the hung-up virtual machine using the PowerShell CLI. Run the PowerShell console with administrator privileges (your account must be added to the local “Hyper-V administrators” group).In this case, the built-inStop-VMcmdlet will not let you shutdown the VM. If you try to run theStop-VM -Forcecommand, it also freezes. Obviously awaiting a response from the VM.

You also need to kill the VM process by its GUID. You can get the VM GUID by its name. For example, to get the GUID of the VM with the name SVM-GUARDEDHOST1, run the command:

$VMGUID = (Get-VM "SVM-GUARDEDHOST1").ID

If you don’t want to type the full name of the VM, you can list all the VMs registered on this Hyper-V host:

Get-VM | Select Name, Id

Copy your VM GUID from the resulting list.

Find the vmwp.exe process identifier (PID) for this VMGUID:

$VMWMProc = (Get-WmiObject Win32_Process | ? {$_.Name -match 'VMWP' -and $_.CommandLine -match $VMGUID})

Then, using the Stop-Process command, you must force-terminate this process:

Stop-Process ($VMWMProc.ProcessId) –Force

This is the easy way to forcefully terminate the working process of a hung-up Hyper-V virtual machine.
Tip. We also have a description of the similar way tokill the process of the hung-up VM on VMWare ESXi.

Hyper-V: Failed to Change VM State

Sometimes it happens that even after killing a hung-up VM process, you cannot turn on the VM. Moreover, it freezes in the Starting state with an error:

Virtual Machine ConnectionFailed to Change State.

In this case, check the following options:

  • Check that there is sufficient free space on the disk on which the Hyper-V VM files are stored;
  • If an ISO image is connected in the VM settings, check its availability;
  • Check the network adapter settings of the VM. Virtual network adapters must be connected to an existing Hyper-V virtual switch (there must be no status Network Adapter –Configuration Errorfor any NIC);
  • Check that the Hyper-V Virtual Management Service (VMMS) is running and didn’tstuck in the Stopping state;
  • Make sure that your antivirus software doesn’t block access to VM files. Add paths to the VM directory to the antivirus exclusions;
  • Check for Hyper-V related errors in the Event Viewer -> Applications and Services Logs -> Microsoft -> Windows -> Hyper-V-Worker.

Tags:

Hyper-V

How to Stop/Kill a Stuck Virtual Machine on Hyper-V | zamarax.com (2024)

References

Top Articles
Latest Posts
Article information

Author: Twana Towne Ret

Last Updated:

Views: 5972

Rating: 4.3 / 5 (44 voted)

Reviews: 91% of readers found this page helpful

Author information

Name: Twana Towne Ret

Birthday: 1994-03-19

Address: Apt. 990 97439 Corwin Motorway, Port Eliseoburgh, NM 99144-2618

Phone: +5958753152963

Job: National Specialist

Hobby: Kayaking, Photography, Skydiving, Embroidery, Leather crafting, Orienteering, Cooking

Introduction: My name is Twana Towne Ret, I am a famous, talented, joyous, perfect, powerful, inquisitive, lovely person who loves writing and wants to share my knowledge and understanding with you.