Forum Discussion

ahinterl's avatar
ahinterl
Brass Contributor
Oct 20, 2025

Map vmdk to guest volume

I have a Hyper-V cluster and want PowerShell to give me a list of what vmdk file is assigned to which volume mount point in the virtual machine OS (Windows). Example:

vmdk file                                                                  mount point
-------------------------------------------------------------------------------------------
C:\ClusterStorage\Data1\VM\ComputerA\Virtual Hard Disks\OSDisk.vhdx        C:\
C:\ClusterStorage\Data1\VM\ComputerA\Virtual Hard Disks\MainMount.vhdx     M:\
C:\ClusterStorage\Data1\VM\ComputerA\Virtual Hard Disks\Temp.vhdx          M:\Temp

The vmdks for C: and M: are mapped to drives in the guest, whereas Temp.vhdx is mounted in a folder under M:\.

The main challenge for me is actually to find the correct elements that allow me to link a VMDK to a disk inside the virtual machine OS. The ones I found so far are: Get-Disk gives me numbers for adapter, port, target, and LUN, and Get-VMHardDiskDrive returns numbers for controller and location, which I guess link to target and LUN. But I'm pretty unsure whether it's safe to use these properties...

Get-Disk returns a path, and I think I can use this to map the result of a win32_mountpoint CIM query to it to get the volume mount point...

Does anyone have some valuable information for me on this?

 

 

 

1 Reply

  • Vern_Anderson's avatar
    Vern_Anderson
    Copper Contributor

    Hello,

    Hyper-V uses VHD and VHDX files it does not natively use VMDKs that is VMWARE's file standard.
    VHD = Generation 1 VM
    VHDX = Generation 2 VM

    The Get-VMHardDiskDrive that is already built in should get you what you need, you could even pipe in all the VM names into it, but by default it gets the VHD information for the VM you specify, but it does accept pipe line input.

    Get-VM | Get-VMHardDiskDrive | Format-Table VMName,ControllerLocation,Path

     

Resources