I got a great question based on yesterday’s post (by the way my e-mail was blocking a lot of external messages that’s fixed now so I apologize to anyone I missed a mail from). The person was asking how they could figure out what physical disk a virtual machine is using when configured for passthough on the host… Well here’s the magic – I took it a little further and got the path’s for any attached VHD’s… Enjoy!
Taylor Brown Hyper-V Integration Test Lead http://blogs.msdn.com/taylorb
PingBack from http://hubsfunnywallpaper.cn/?p=1812
Very handy script by Taylor Brown I got a great question based on yesterday’s post (by the way my e-mail
You are asking Hyper-V parent's Hyper-V WMI provider to answer which one is VHD / passthrough disk.
Without asking parent, how to detect?
=========================================Without asking the parent you can't detect this information.
-Taylor
If anyone is trying to do this in VBScript then here's the code:
strComputer = ""
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\virtualization")
Set colSystems = objWMIService.ExecQuery("SELECT * FROM Msvm_VirtualSystemSettingData", _
"WQL", wbemFlagReturnImmediately + wbemFlagForwardOnly)
For Each objSystem In colSystems
WScript.Echo "ElementName: " & objSystem.ElementName
Set colResData = objWMIService.ExecQuery("Associators of {Msvm_VirtualSystemSettingData='" & objSystem.InstanceID & "'} Where ResultClass=Msvm_ResourceAllocationSettingData AssocClass=Msvm_VirtualSystemSettingDataComponent", _
For Each objResData In colResData
If objResData.ResourceSubType = "Microsoft Virtual Hard Disk" Then
strConnection = Join(objResData.Connection, ",")
WScript.Echo " Connection: " & strConnection
End If
Next
This is a follow up on my previous post on Hyper-V WMI: What VHD’s/Physical Disks Are Associated With
is there an easy way to determine the type of a virtual disk - ie. fixed, dynamic, differencing?
and if differencing - what is the parent?