Listing all your VHD and VHDX files from your Hyper-V Hosts in Windows Server 2012

Hello Hyper-V fans! 

As you know, Windows Server 2012 Hyper-V is available since past October and comes with hundreds of new features and improvements. Today I want to give you a small bite of what you can do with the new native PowerShell module for Hyper-V that includes more than 300 cmdlets. Nowadays, all of you that are using Hyper-V, probably have an increasing number of VMs with their own virtual disks that may be difficult to track or remember where they are stored. Of course we can go to each VM on the Hyper-V Manager and check the settings of the virtual disks to see where they are and what type of VHD or VHDX…. But this can be annoying and time consuming right? So here is all what you need to do to get a complete list of all your virtual disks in your Hyper-V hosts in Windows Server 2012.

· Step 1: Open Powershell or the new Powershell ISE console

· Step 2: Type the following commands


foreach($VM in $VMs ){Get-VHD -VMId $VM.VMId}


The output of this command will enumerate all your virtual disks of all your VMs in your Hyper-V host and will also give detailed information about each of them. Here is an example of the output of one VHDX file in my lab.


Hope that it was useful and see you in my next post.


Cristian Edwards

Comments (0)

Skip to main content