Using PowerShell to List VHDs Used On a Hyper-V Host

Use PowerShell to list every VHD used on a Hyper-V host.

John Savill

September 2, 2013

1 Min Read
Using PowerShell to List VHDs Used On a Hyper-V Host

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.

$VMs = Get-VMForeach ($VM in $VMs){  $HardDrives = $VM.HardDrives  Foreach ($HardDrive in $HardDrives)  {    $HardDrive.path | Get-VHD  }}

 

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

About the Author

Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like