Windows OS Hub
  • Windows Server
    • Windows Server 2022
    • Windows Server 2019
    • Windows Server 2016
    • Windows Server 2012 R2
    • Windows Server 2012
    • Windows Server 2008 R2
    • SCCM
  • Active Directory
    • Active Directory Domain Services (AD DS)
    • Group Policies
  • Windows Clients
    • Windows 11
    • Windows 10
    • Windows 8
    • Windows 7
    • Windows XP
    • MS Office
    • Outlook
  • Virtualization
    • VMWare
    • Hyper-V
    • KVM
  • PowerShell
  • Exchange
  • Cloud
    • Azure
    • Microsoft 365
    • Office 365
  • Linux
    • CentOS
    • RHEL
    • Ubuntu
  • Home
  • About

Windows OS Hub

  • Windows Server
    • Windows Server 2022
    • Windows Server 2019
    • Windows Server 2016
    • Windows Server 2012 R2
    • Windows Server 2012
    • Windows Server 2008 R2
    • SCCM
  • Active Directory
    • Active Directory Domain Services (AD DS)
    • Group Policies
  • Windows Clients
    • Windows 11
    • Windows 10
    • Windows 8
    • Windows 7
    • Windows XP
    • MS Office
    • Outlook
  • Virtualization
    • VMWare
    • Hyper-V
    • KVM
  • PowerShell
  • Exchange
  • Cloud
    • Azure
    • Microsoft 365
    • Office 365
  • Linux
    • CentOS
    • RHEL
    • Ubuntu

 Windows OS Hub / Virtualization / Hyper-V / How to Stop/Kill a Stuck Virtual Machine on Hyper-V?

January 16, 2020 Hyper-VWindows Server 2016Windows Server 2019

How to Stop/Kill a Stuck Virtual Machine on Hyper-V?

If your virtual machine running on Hyper-V is stuck for some reason, stopped to respond 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. We’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 and Live-Migration).

Contents:
  • Hyper-V VM Stuck in the “Stopping/Starting” State
  • Hyper-V Manager Stuck on “Connecting to Virtual Machine Management Service”
  • How to Kill a Hung VM Process in Task Manager?
  • Killing a Frozen Hyper-VM using PowerShell
  • Hyper-V: Failed to Change VM State

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

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

hyper-v vm stuck in the stopping 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.

The application encountered an error while attempting to change the state of … 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 the vmms.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 the PowerShell service management cmdlets:

Get-Service vmms | Restart-Service

posh: restart-service vmms

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 the vmwp.exe process (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 the Hyper-V Manager console. Open the Hyper-V server settings. In the Server section, the location of the VM configuration files is shown (in our case it is D:\VMStore).

Hyper-V Settings

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.

vm guid in file name

Run the Task Manager and go to the Details tab. All virtual machines are running in their own instance of vmwp.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 the User name column. Kill this process (End Task).

kill hung vm on hyper-v using task manager

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 the administrator privileges (your account must be added to the local “Hyper-V administrators” group).

In this case, the built-in Stop-VM cmdlet will not let you shutdown the VM. If you try to run the Stop-VM -Force command, 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

get-vm guid in powershell

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
Killing Hung VM on Hyper-V using Powershell

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 to kill 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 Connection
Failed 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 Error for any NIC);hyper-v network-adapter configuration error
  • Check that the Hyper-V Virtual Management Service (VMMS) is running and didn’t stuck 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 (please, check how to add exclusions to the built-in Windows Defender antivirus on Windows Server 2016);
  • Check for Hyper-V related errors in the Event Viewer -> Applications and Services Logs -> Microsoft -> Windows -> Hyper-V-Worker.

13 comments
3
Facebook Twitter Google + Pinterest
previous post
How to Check If a PowerShell Script Is Run As Administrator?
next post
How to Manage NTFS Permissions with PowerShell?

Related Reading

Create Organizational Units (OU) Structure in Active Directory...

May 17, 2022

RDS and RemoteApp Performance Issues on Windows Server...

May 16, 2022

Deploying Software (MSI Packages) Using Group Policy

May 12, 2022

How to Completely Uninstall Previous Versions of Office...

April 26, 2022

Install and Configure SNMP Service on Windows Server...

April 21, 2022

13 comments

Sergey Mozhzhukhin December 6, 2017 - 8:11 pm

It’s easy to kill VM but it doesn’t start anymore if you do this. You have to restart host.

Reply
Tim N April 13, 2018 - 12:51 pm

I tried to kill the VM this way and it said access denied, even though I was logged in as the administrator!

Reply
Max April 16, 2018 - 9:19 am

Ensure that your account is a member of the local group Hyper-V administrators and you have started elevated PoSh console.

Reply
Matt December 24, 2020 - 10:40 pm

Killing vmwp.exe intermittently works. User is member or hyperv admins, powershell started as admin. Killing process initially accepted but the proem was doesn’t die. Further attempts result in access denied errors.

Sometimes it’ll die on the first attempt to kill. If it doesn’t die then further attempts become pointless and hose restart is required.

Reply
ZEP June 27, 2018 - 8:23 pm

Never had luck with this on Server 2012r2. I always end up rebooting the host to fix the issue.

Reply
Hyper-V マネージャー 停止中 重大 - Blog - MarvelWorks August 1, 2018 - 6:34 am

[…] 下記の海外サイトで、プロセスを特定して停止させようとするケースは、VMが起動しているが、 反応がないフリーズした状態の時のみ有効のようです。 http://woshub.com/how-to-stop-a-hung-virtual-machine-on-hyper-v-2016/ […]

Reply
Himanshu Pawar August 6, 2018 - 1:59 pm

If Its Windows 10 pro Test environment machines , Just remove the feature restart host system and add Hyper v feature again your VM will be showing in saved state just Add Virtual switch and add to the VMs for those you were facing problem in startup.Now delete the save state and start the VM you will get your machine ready.

Reply
Jan Laursen September 7, 2018 - 9:08 am

Thank You – was just about to throw my host machine out the window 🙂

Reply
Marko Čepe May 22, 2019 - 8:59 pm

This procesdure saved my life multiple-times on 2016 and on 2012R2 also. As soon as I killed the proccess, the VM restarted it self and booted back to normal

Reply
Mark August 8, 2020 - 8:44 am

Thanks, thanks, thanks!
I’ve had a CPU usage of about 15/20% for a while, just because a VM was hanging shutting down. I had all the Hyper-V processed stopped, but still.
Following your guide forced the VM to stop and the vmmem process stopped using the CPU!

Reply
Vinod December 9, 2020 - 7:17 am

Thanks a lot. I was trying wsl –shutdown from one day but it was not working. As last your GUI based solution solved my problem.

Reply
Josh August 6, 2021 - 4:42 pm

Unlcear where the VMSTORE directory is

Reply
Martin October 6, 2021 - 8:43 pm

Pinche menso

Reply

Leave a Comment Cancel Reply

Categories

  • Active Directory
  • Group Policies
  • Exchange Server
  • Microsoft 365
  • Azure
  • Windows 11
  • Windows 10
  • Windows 7
  • Windows Server 2019
  • Windows Server 2016
  • Windows Server 2012 R2
  • PowerShell
  • VMWare
  • Hyper-V
  • MS Office

Recent Posts

  • Create Organizational Units (OU) Structure in Active Directory with PowerShell

    May 17, 2022
  • Windows Security Won’t Open or Shows a Blank Screen on Windows 10/ 11

    May 17, 2022
  • How to Manually Install Windows Updates from CAB and MSU Files?

    May 16, 2022
  • RDS and RemoteApp Performance Issues on Windows Server 2019/2016

    May 16, 2022
  • Deploying Software (MSI Packages) Using Group Policy

    May 12, 2022
  • Updating VMware ESXi Host from the Command Line

    May 11, 2022
  • Enable or Disable MFA for Users in Azure/Microsoft 365

    April 27, 2022
  • Fix: You’ll Need a New App to Open This Windows Defender Link

    April 27, 2022
  • How to Reset an Active Directory User Password with PowerShell and ADUC?

    April 27, 2022
  • How to Completely Uninstall Previous Versions of Office with Removal Scripts?

    April 26, 2022

Follow us

woshub.com

ad

  • Facebook
  • Twitter
  • RSS
Popular Posts
  • Windows Server Licensing for Virtual Environments
  • How to Install and Configure Free Hyper-V Server 2019/2016?
  • USB Device Passthrough (Redirect) to Hyper-V Virtual Machine
  • How to Backup Hyper-V Virtual Machines?
  • Import, Export and Clone Virtual Machines in Hyper-V
  • How to Extend or Shrink Virtual Hard Disks on Hyper-V?
  • Hyper-V Boot Error: The Image’s Hash and Certificate Are not Allowed
Footer Logo

@2014 - 2018 - Windows OS Hub. All about operating systems for sysadmins


Back To Top