WMI, Hyper-V: What Virtual Machines are being used by a Physical Hard Disk? RRS feed

  • Question

  • In the Hyper-V management application I am abel to assign a Physical Hard Disk to a Virutal Machine (as opposed to a .vhd file).

    In WMI I am able to get all the Physical Hard Disks available via the command:

    SELECT * FROM Msvm_DiskDrive Where Description = 'Microsoft Physical Hard Drive'

    But I can't find any way to map this DiskDrive to what Virtual Machine.  If the DiskDrive is a .vhd file I am to match it up to LogicalDisk and then the ResourceAllocationSettingData which gives me the Virtual Machine.

    Is there any way to do something similar with Physical Hard Disks?

    An example in C# would be a great too.
    Monday, July 14, 2008 5:54 PM

All replies

  • I found the answer as to how to map Physical Hard Disks to Virtual Machines.

    In WMI get the ResourceAllocationSettingData where the resource sub-type is "Microsoft Physical Disk Drive":

    SELECT * FROM Msvm_ResourceAllocationSettingData WHERE ResourceSubType = 'Microsoft Physical Disk Drive'

    From there you can:
    1. Find the correct SettingData byUsing the HostResource attribute and matching it to the Phsyical Hard Disk
    2. Associated it to a Virtual Machine using the InstanceID attribute
    Wednesday, July 16, 2008 5:15 PM