Michael Michael's Blog on How to get the BIOS GUID from a Hyper-V VM - Virtual Machine Management - Site Home - TechNet Blogs

Virtual Machine Management

Managing Virtual & Physical Computers in the Datacenter and in the Cloud

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

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

  • Comments 1
  • Likes

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

Comments
  • <p>When managing a large number of virtual machines, there is often a need to tag it in some way with one</p>