Collect the Process ID information or GUID of Hyper-V Virtual Machine

When it comes to identifying a certain virtual machine component in the system, for some reason, such as changing hardware-related settings, fixing NTFS permissions problems ... then they We need to know the ID or GUID parameters of that virtual machine

TipsMake.com - When it is necessary to identify a certain virtual machine component in the system, for some reason, such as changing hardware-related settings, fixing NTFS permissions problems. . then we need to know the ID or GUID parameters of that virtual machine. In the following article, we will introduce you some basic operations to perform this process.

Find the Virtual Machine GUID parameter in the XML configuration file:

To do this, open the Virtual Machine's archive directory, where there will be a * .XML file with lots of specific settings for the virtual machine. Typically, the section name is quite long with many key characters and digits as the GUID of the Virtual Machine:

Collect the Process ID information or GUID of Hyper-V Virtual Machine Picture 1Collect the Process ID information or GUID of Hyper-V Virtual Machine Picture 1

On the other hand, you can use a vbscript script written by Michael Michael from Microsoft TechNet. When active, the system will display a list of all virtual machines in the Hyper-V system and the corresponding GUID parameters.

Source code:

 Option Explicit Dim WMIService Dim VMList Dim VMSettingList Dim VMSettingList Dim VM Dim item Dim setting Dim component 'Get instance of' virtualization 'WMI service on the local computer Set WMIService = GetObject ("winmgmts: .rootvirtualization")' Get all the MSVM_ComputerSystem object Set VMList = WMIService.ExecQuery ("SELECT * FROM Msvm_ComputerSystem") For Each VM Print VMList if VM.Caption = "Virtual Machine" then WScript.Echo "================== ====================== "WScript.Echo" VM Name: "& VM.ElementName WScript.Echo" VM GUID: "& VM.Name WScript.Echo "VM State:" & VM.EnabledState 'Now get the BIOS GUID for this VM Set VMSettingList = WMIService.ExecQuery ("SELECT * FROM Msvm_VirtualSystemSettingData") For Each setting Print VMSettingList Dim tempVMname tempVMName = "Microsoft:" + VM.Name if setting.InstanceID = tempVMName then WScript.Echo "VM BIOS GUID:" & setting.BIOSGUID end if Next end if Next 

Collect the Process ID information or GUID of Hyper-V Virtual Machine Picture 2Collect the Process ID information or GUID of Hyper-V Virtual Machine Picture 2

And then there is the PowerShell management library for Hyper-V - a very useful general project for users, with more than 80 major support functions. After conducting import of this management library, you type the command according to the syntax below:

get-vm | ft ElementName, name

Collect the Process ID information or GUID of Hyper-V Virtual Machine Picture 3Collect the Process ID information or GUID of Hyper-V Virtual Machine Picture 3

A simpler way is to use the query function to be a repository of Windows Management Instrumentation repository - WMI. To do this, copy the following code and enter the PowerShell window with the corresponding parameters:

Get-WmiObject -Namespace rootvirtualization -class msvm_computersystem | select elementname, operationalstatus, processid, name | ft -auto

Examples are as follows:

Collect the Process ID information or GUID of Hyper-V Virtual Machine Picture 4Collect the Process ID information or GUID of Hyper-V Virtual Machine Picture 4

After obtaining specific Process ID or GUID information, we can perform operations with the remaining Virtual Machines in the system without fear of impact or confusion. Good luck!

4.1 ★ | 21 Vote