Q: How can I quickly get a list of every virtual hard disk (VHD) that's being used by a virtual machine (VM) on a Hyper-V host?

A: The Windows PowerShell script below finds all VMs on the current host, then lists all the VHDs associated with the VMs.

  1. $VMs = Get-VM
  2. Foreach ($VM in $VMs)
  3. {
  4. $HardDrives = $VM.HardDrives
  5. Foreach ($HardDrive in $HardDrives)
  6. {
  7. $HardDrive.path | Get-VHD
  8. }
  9. }

See also "Using PowerShell to List VHDs In a Hyper-V Cluster."