If your virtual machine running on Hyper-V has hung up for some reasons, stopped to respond and doesn’t start/stop/reset after clicking the corresponding buttons in Hyper-V console, the only way out is to kill the process responsible for this VM on the host OS. We’ll show how to do it on Hyper-V running on Windows Server 2016.
Suppose, that one of your Hyper-V VMs has hung up, the guest OS doesn’t respond and Turn Off, Shut Down and Reset buttons in Hyper-V Manager either are unavailable, or return the following error:
Failed to change state
The operation cannot be performed while the object is in its current state
To force stop/restart this VM without the restart of the whole host server, you have to end the process of this VM. To do it, you need get the GUID of the virtual machine.
Open Hyper-V Settings of Hyper-V Manager. In Server section, the location of the VM config files is shown (in our case it is D:\VMStore).
Go to this directory and locate the folder with the same name as your virtual machine has. Remember the GUID specified in the name of the VM configuration files name.
Start Task Manager and go to 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. Find the process vmwp.exe with this GUID shown in User name column. End this process (End Task).
The virtual machine will be stopped. Now you can do anything with it.
But! It’s much easier to find and end the process of the hung-up virtual machine using PowerShell. In this case, we’ll need only its name.
Get the GUID of the VM with the name SVM-GUARDEDHOST1:
$VMGUID = (Get-VM "SVM-GUARDEDHOST1").ID
Find the identifier of vmwp.exe for this VMGUID:
$VMWMProc = (Get-WmiObject Win32_Process | ? {$_.Name -match 'VMWP' -and $_.CommandLine -match $VMGUID})
Force this task to stop using Stop-Process:
Stop-Process ($VMWMProc.ProcessId) –Force
This is the way to easily forcefully terminate the working process of a hung-up Hyper-V virtual machine.
7 comments
It’s easy to kill VM but it doesn’t start anymore if you do this. You have to restart host.
I tried to kill the VM this way and it said access denied, even though I was logged in as the administrator!
Ensure that your account is a member of the local group Hyper-V administrators and you have started elevated PoSh console.
Never had luck with this on Server 2012r2. I always end up rebooting the host to fix the issue.
[…] 下記の海外サイトで、プロセスを特定して停止させようとするケースは、VMが起動しているが、 反応がないフリーズした状態の時のみ有効のようです。 http://woshub.com/how-to-stop-a-hung-virtual-machine-on-hyper-v-2016/ […]
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.
Thank You – was just about to throw my host machine out the window 🙂