View VM Virtual Hard Disks

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:\virtuals\savdalcm12\Virtual Hard Disks\savdalcm12.vhdx          
savdaldc01         IDE            0                0                             E:\virtuals\savdaldc01\Virtual Hard Disks\savdaldc01.vhdx          
savdaldpm12        IDE            0                0                             E:\virtuals\savdaldpm12\Virtual Hard Disks\savdaldpm12.vhdx        
savdalex01         IDE            0                0                             E:\virtuals\savdalex01\Virtual Hard Disks\savdalex01.vhdx          
savdalfs01         IDE            0                0                             E:\virtuals\savdalfs01\Virtual Hard Disks\savdalfs01.vhdx          
savdalfs01         SCSI           0                0                             E:\virtuals\savdalfs01\Virtual Hard Disks\savdalfs01-data.vhdx     
savdaliscsi01      IDE            0                0                             E:\virtuals\savdaliscsi01\Virtual Hard Disks\savdalicsi01.vhdx     
savdaliscsi01      SCSI           0                0                             E:\virtuals\savdaliscsi01\Virtual Hard Disks\data1.vhdx            
savdaliscsi01      SCSI           0                1                             E:\virtuals\savdaliscsi01\Virtual Hard Disks\datadisk2.vhdx        
savdaliscsi01      SCSI           0                2                             E:\virtuals\savdaliscsi01\Virtual Hard Disks\data3.vhdx            
savdalois12        IDE            0                0                             E:\virtuals\savdalois12\Virtual Hard Disks\savdalois12.vhdx        
savdalops12        IDE            0                0                             E:\virtuals\savdalops12\Virtual Hard Disks\savdalops12.vhdx        
savdalrds01        IDE            0                0                             E:\virtuals\savdalrds01\Virtual Hard Disks\savdalrds01.vhdx        
savdalrdsgw        IDE            0                0                             E:\virtuals\savdalrdsgw\Virtual Hard Disks\savdalrdsgw.vhdx        
savdalsm12         IDE            0                0                             E:\virtuals\savdalsm12\Virtual Hard Disks\savdalsm12.vhdx          
savdalsmdw12       IDE            0                0                             E:\virtuals\savdalsmdw12\Virtual Hard Disks\savdalsmdw12.vhdx      
savdalsmweb12      IDE            0                0                             E:\virtuals\savdalsmweb12\Virtual Hard Disks\savdalsmweb12.vhd     
savdalsps01        IDE            0                0                             E:\virtuals\savdalsps01\Virtual Hard Disks\savdalsps01.vhdx        
savdalsql01        IDE            0                0                             E:\virtuals\savdalsql01\Virtual Hard Disks\savdalsql01.vhdx        
savdalvmm12        IDE            0                0                             E:\virtuals\savdalvmm12\Virtual Hard Disks\savdalvmm12.vhdx        
savdalw8e01        IDE            0                0                             E:\virtuals\savdalw8e01\Virtual Hard Disks\savdalw8e01.vhdx        
savdalync01        IDE            0                0                             E:\virtuals\savdalync01\Virtual Hard Disks\svadalync01.vhdx        
Scratch2012        IDE            0                0                             E:\virtuals\Scratch2012\Virtual Hard Disks\Scratch2012.vhdx        
Scratch2012Std     IDE            0                0                             E:\virtuals\Scratch2012Std\Virtual Hard Disks\Scratch2012Std.vhdx  
Win8Template (VDI) IDE            0                0                             E:\virtuals\Win8Template (VDI)\Virtual Hard Disks\Win8Template.vhdx

 

Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish