TechOnTip Weblog

Run book for Technocrats

Hyper-V Virtual Machine Process ID & GUID

Posted by Brajesh Panda on May 12, 2011

You can find the server GUID from the VM config XML file. Usually the XML file is named as the VM Name. And you will find the config file in the Virtual Machine folder. But if you have not changed the default path for the virtual machine config folder in Hyper-V Management console you will end up having all XML config files in the same folder. Then it will be difficult to find out which file is pointing to which server.

Here are some easy methods to find out all virtual machines, their operational state, and their process ID & GUID. All these information are usually stored in WMI namespace root\virtualization & class msvm_computersystem. So we are going to query the WMI namespace & retrieve all these info. Screenshots were taken on different times after multiple time of kill operation, so process ID may be different in each screen shot ;-(

Using Powershell

Get-WmiObject -Namespace root\virtualization -class msvm_computersystem | select elementname, operationalstatus, processid, name| ft -auto


Here is another method; you can query for a specific virtual machine too.

(gwmi -q “SELECT * FROM Msvm_ComputerSystem WHERE ElementName = ‘brajesh'” -n root\virtualization).ProcessID

Where “brajesh” is the Virtual Machine Name displayed in the Hyper-v console.

Using VB Script

Here is the WMI script created by Michael which retrieves the VM GUID, BIOS GUID. Save this script as a VBS file & run it as “cscript <filename>”

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Option Explicit
Dim WMIService
Dim KvpComponents
Dim VMList
Dim VMSettingList
Dim VM
Dim item
Dim setting
Dim component

‘Get instance of ‘virtualization’ WMI service on the local computer
Set WMIService = GetObject(“winmgmts:\\.\root\virtualization”)
‘Get all the MSVM_ComputerSystem object
Set VMList = WMIService.ExecQuery(“SELECT * FROM Msvm_ComputerSystem”)
For Each VM In 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 In 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

Using this script I found my VM as “D756AC93-6711-4854-A6CE-E42B4978A505”


Advertisements

One Response to “Hyper-V Virtual Machine Process ID & GUID”

  1. […] Hyper-V Virtual Machine Process ID & GUID […]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: