A: If you mounted a virtual hard disk (VHD) and want to check its drive letter, use the following two Windows PowerShell commands:

 

  1. $DiskNumber = (Get-VHD “d:\temp\temp2gb.vhdx”).DiskNumber<br>
  2. $DriveLetter = (gwmi Win32_DiskPartition -filter "DeviceID like 'Disk #$DiskNumber,%'").PSBase.GetRelated('Win32_LogicalDisk') | Select-object -ExpandProperty DeviceID

Another option using PowerShell, is to enter this:

$disks = Get-CimInstance -ClassName Win32_DiskDrive | where Caption -eq "Microsoft Virtual Disk" <br>
  1. foreach ($disk in $disks){ <br>
  2.    $vols = Get-CimAssociatedInstance -CimInstance $disk -ResultClassName Win32_DiskPartition <br>
  3.    foreach ($vol in $vols){ <br>
  4.        Get-CimAssociatedInstance -CimInstance $vol -ResultClassName Win32_LogicalDisk | <br>
  5.           where VolumeName -ne 'System Reserved' <br>
  6.    } <br>
}

Here's an example of output I received:

DeviceID DriveType ProviderName VolumeName Size FreeSpace -------- --------- ------------ ---------- ---- --------- N: 3 TempVHD 2111827968