How to get the BIOS GUID from a Hyper-V VM

Hi all, the below vbscript (save as sample.vbs and execute using "cscript.exe sample.vbs"), will give you a list of all VMs in a hyper-v system as well as their respective BIOS GUIDs. This can help in troubleshooting VMM 2008 beta for the cases where more than 1 VM on the same hyper-v host is having the same BIOS ID.

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
 end if

Comments (1)
  1. Anonymous says:

    When managing a large number of virtual machines, there is often a need to tag it in some way with one

Comments are closed.

Skip to main content