Q: How can I get a full list of every virtual hard disk (VHD) being used by virtual machines (VMs) running in a cluster of Hyper-V hosts?

A: The Windows PowerShell script below extends the code from "List Every VHD Used on a Hyper-V Host," which helps you quickly get a list of every VHD being used by a VM on a Hyper-V host and gets all resource types that are VMs from a cluster.

Note that the code to get the details of the disk is executed on the node currently running the VM.

$VMs = Get-ClusterGroup | ? { $_.GroupType –eq “VirtualMachine” } | Get-VM
Foreach ($VM in $VMs)
$HardDrives = $vm.HardDrives
Invoke-Command –ComputerName $vm.computername –scriptblock
Foreach ($HardDrive in $HardDrives){$HardDrive.Path | Get-VHD}
} –Args $HardDrives