Identify Hyper-V VM by worker process if VM is hung on Starting/Snapshotting/Stopping

It’s easy to restart a running VM from Hyper-V Manager but when you have a situation where a number of VM’s running on a production server and you are not able to do this from the Hyper-V manager.

In this case you can make use of VM worker to restart the VM without affecting any other Virtual machines.

pic01

For each VM running on Hyper-V would have a virtual machine worker process associated with it, so our goal is to find the associated VM worker and kick that off – This will restart the VM immediately.

  1. Use the below Script to find out the PID of hung VM (Replace the “VM Name” with your VM)

(Get-WmiObject -q “SELECT * FROM Msvm_ComputerSystem WHERE ElementName = ‘VMName'” -n root\virtualization\v2).ProcessID

PS C:\Windows\system32> (Get-WmiObject -q "SELECT * FROM Msvm_ComputerSystem WHERE ElementName = 'VMName'" -n root\v
irtualization\v2).ProcessID
2676
PS C:\Windows\system32>

2. Now you can use Kill command to restart the VM

pic3

This will restart the VM immediately .When you have a minimum number of VM’s running you can use the task manager to identify the process ID which is associated with the VM GUID.

 

An absolute beginner’s guide to Microsoft Hyper-V

Virtualization is the creation of a virtual version of an IT environment which includes an operating system, a storage device, a network device, etc. The Hypervisor is the processor-specific virtualization platform that can host multiple virtual machines (VMs) that are isolated from each other but share the underlying hardware resources by visualizing the processors, memory, and I/O devices.

Microsoft introduced Hyper-V as a virtualization platform in 2008 and it continued to release new Hyper-V versions with new windows server versions. So far there are a total of four versions including windows server 2012 R2,Windows server 2012,windows server 2008 R2 and windows server 2008( Not including windows server 2016 now).

Hyper-V is a hybrid Hypervisor which is installed from operating system, however doing the installation it redesigns the OS architecture.

 

hyp-v

The magical transformation, when you add Hyper-V role in windows server *

                                           You first install windows server operating system at this point there is no hypervisor. When you enable Hyper-V role windows will install all required software components like VMBus and VSP but not the hypervisor. Instead windows installs the device driver Hvboot.sys, which will load the actual hypervisor on the next boot. This can be either %system root%system 32%Hvax64.exe for AMD processor %systemroot%system32%Hvix64.exe .These files are very small in size. Once loaded, the hypervisor used the virtualization extension of the CPU to inset as a ring -1 process, taking over the control of the hardware. It proceeds to load the windows server 2012  kernel to the parent partition, prepared with VMBus and VSP. Here your Hyper-V is ready to start .

Hyper-V is a great option for consolidating your server hardware,If you want to experiment with Hyper-V and you can try doing experiments with your windows 10 workstation.