View VM Virtual Hard Disks

To view virtual machines' hard disks, use this Windows PowerShell command.

John Savill

March 6, 2013

1 Min Read
View VM Virtual Hard Disks

Q: How can I easily see the virtual hard disks for all virtual machines on a certain disk?

A: To see virtual hard disks (VHDs) for virtual machines (VMs), use the Windows PowerShell script below. It lists all VMs, gets the hard disks for those VMs, and then tests if the path of that VHD starts with the desired drive letter, in this case the E: drive.

You must have the Hyper-V PowerShell module imported (although in PowerShell 3.0 the import will happen automatically--still, use Import-Module Hyper-V to avoid any possible ambiguity of modules used).

PS C:> Get-VM | Get-VMHardDiskDrive | where {$_.Path.StartsWith("E:")} VMName             ControllerType ControllerNumber ControllerLocation DiskNumber Path                                                               ------             -------------- ---------------- ------------------ ---------- ----                                                               savdalcm12         IDE            0                0                             E:virtualssavdalcm12Virtual Hard Diskssavdalcm12.vhdx          savdaldc01         IDE            0                0                             E:virtualssavdaldc01Virtual Hard Diskssavdaldc01.vhdx          savdaldpm12        IDE            0                0                             E:virtualssavdaldpm12Virtual Hard Diskssavdaldpm12.vhdx        savdalex01         IDE            0                0                             E:virtualssavdalex01Virtual Hard Diskssavdalex01.vhdx          savdalfs01         IDE            0                0                             E:virtualssavdalfs01Virtual Hard Diskssavdalfs01.vhdx          savdalfs01         SCSI           0                0                             E:virtualssavdalfs01Virtual Hard Diskssavdalfs01-data.vhdx     savdaliscsi01      IDE            0                0                             E:virtualssavdaliscsi01Virtual Hard Diskssavdalicsi01.vhdx     savdaliscsi01      SCSI           0                0                             E:virtualssavdaliscsi01Virtual Hard Disksdata1.vhdx            savdaliscsi01      SCSI           0                1                             E:virtualssavdaliscsi01Virtual Hard Disksdatadisk2.vhdx        savdaliscsi01      SCSI           0                2                             E:virtualssavdaliscsi01Virtual Hard Disksdata3.vhdx            savdalois12        IDE            0                0                             E:virtualssavdalois12Virtual Hard Diskssavdalois12.vhdx        savdalops12        IDE            0                0                             E:virtualssavdalops12Virtual Hard Diskssavdalops12.vhdx        savdalrds01        IDE            0                0                             E:virtualssavdalrds01Virtual Hard Diskssavdalrds01.vhdx        savdalrdsgw        IDE            0                0                             E:virtualssavdalrdsgwVirtual Hard Diskssavdalrdsgw.vhdx        savdalsm12         IDE            0                0                             E:virtualssavdalsm12Virtual Hard Diskssavdalsm12.vhdx          savdalsmdw12       IDE            0                0                             E:virtualssavdalsmdw12Virtual Hard Diskssavdalsmdw12.vhdx      savdalsmweb12      IDE            0                0                             E:virtualssavdalsmweb12Virtual Hard Diskssavdalsmweb12.vhd     savdalsps01        IDE            0                0                             E:virtualssavdalsps01Virtual Hard Diskssavdalsps01.vhdx        savdalsql01        IDE            0                0                             E:virtualssavdalsql01Virtual Hard Diskssavdalsql01.vhdx        savdalvmm12        IDE            0                0                             E:virtualssavdalvmm12Virtual Hard Diskssavdalvmm12.vhdx        savdalw8e01        IDE            0                0                             E:virtualssavdalw8e01Virtual Hard Diskssavdalw8e01.vhdx        savdalync01        IDE            0                0                             E:virtualssavdalync01Virtual Hard Diskssvadalync01.vhdx        Scratch2012        IDE            0                0                             E:virtualsScratch2012Virtual Hard DisksScratch2012.vhdx        Scratch2012Std     IDE            0                0                             E:virtualsScratch2012StdVirtual Hard DisksScratch2012Std.vhdx  Win8Template (VDI) IDE            0                0                             E:virtualsWin8Template (VDI)Virtual Hard DisksWin8Template.vhdx

 

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