Get Hyper-V Virtual Machine Process ID and GUID
When needing to manipulate a virtual machine – either kill it if it’s unresponsive, or do other management tasks such as working with virtual disks or snapshots and even fixing specific issues with NTFS file permissions – it may be useful to know the virtual machine ID or GUID. In this brief article, we’ll show you where to find the process ID and GUID.
Find Virtual Machine GUID in XML Config File
If you look at the folder where the VM is located, you’ll find an .XML file that contains the configuration information for the VM. This file name uses a long GUID string, which in fact is identical to the VM’s GUID.
Other Methods to Obtain ID and GUID
This is a good script written by Michael Michael from Microsoft. It will give you a list of all VMs in a hyper-v system as well as their respective BIOS GUIDs.
How to get the BIOS GUID from a Hyper-V VM – Virtual Machine Management – Site Home – TechNet Blogs
Next, a good resource to know, the PowerShell management Library for Hyper-V, a project to provide a PowerShell management library for Hyper-V. It does pretty much what it says, with 80 functions in the library.
PowerShell Management Library for Hyper-V
After importing the management library, run a command such as this one:
get-vm | ft ElementName,name
Another easy to use method is by querying the WMI repository.
Copy the following command and enter it in a PowerShell window with elevated credentials:
Get-WmiObject -Namespace root\virtualization -class msvm_computersystem | select elementname, operationalstatus, processid, name| ft -auto
After finding either the Process ID or the GUID, here is how you can kill a hung VM without affecting the other VMs on the host.
Knowing a VM’s ID or GUID can be useful whenever you need kill a hung VM or do other management tasks to a specific VM, especially if there are multiple VM’s running on one machine. I hope this brief article has shown you some useful ways of obtaining a VM’s ID and GUID.
More in Hyper-V
How to Install Hyper-V on Windows Server Core
Mar 16, 2022 | Michael Reinders
Microsoft Says There Will Be No Hyper-V Server 2022 Free Edition
Dec 13, 2021 | Michael Reinders
How to Stop an Unresponsive Hyper-V Virtual Machine
Jun 29, 2021 | Russell Smith
How to Enable Nested Virtualization in Hyper-V
Jun 28, 2021 | Russell Smith
Disaster Recovery with Azure Backup for SQL Server VMs
May 28, 2019 | Michael Otey
Leveraging Virtualization for Improved Availability and Disaster Recovery
Apr 29, 2019 | Michael Otey
Most popular on petri