List Hyper-V VMs with missing VHDs

#Powershell #HyperV

I read a great post by Benjamin Armstrong [A] with a one-line Powershell command to list virtual machines in Hyper-V that have a missing or broken VHD disk.

This helped me do some weeding on some Hyper-V machines and clean up old/stale VMs.

get-vm | Get-VMHardDiskDrive | %{write-host $_.VMName.PadRight(40) ":: VHD Exists :: "-NoNewline; Test-Path $_.Path}

Just putting this here for my notes.

Discuss...