PowerShell script to list available disk space in dynamic VHD files

In my test environment I just about always use dynamic VHD’s.
Because I do not always remember what maximum size I set to every VHD, I wanted to create a list with the space that was still available within the dynamic VHD… in other words, how much space is still available before the VHD reaches its limit?
As usual, the answer to that question is PowerShell…

Get-VirtualHardDisk -VMMServer SCVMM -All | Select-Object @{Label=”Name”;Expression={$_.Name}},@{Label=”Space available”;Expression={[Math]::Truncate(($_.MaximumSize-$_.Size) / 1GB)}},@{Label=”Host”;Expression={$_.VMHost}} | Where-Object {($_.VHDType -Match “DynamicallyExpanding” -And $_.Name -NotMatch “{“)} | Sort-Object “Space available” –Descending

And if you want to redirect the information (in case you have a large environment) to a CSV file, just put “ |  Export-Csv C:\DynamicAvailable.csv” behind the command.

Note: Use this script when the SCVMM PowerShell Module is loaded.


  1. carlos says:

    Hi Friend! Good script! But i can show this for VM? or only for VirtualDisk?
    look, i need information about maximumSize for vm:

    VM1 – size-MaximumSize2GB
    Can you this script? sorry my bad english im brazilian! 🙂

  2. Jeff Wouters says:

    Hi Carlos,

    No problem, here you go:
    Get-VirtualHardDisk -VMMServer SCVMM | Select-Object @{Label=”Name”;Expression={$_.Name}},@{Label=”VHD Maximum Size”;Expression={[Math]::Truncate($_.Size / 1GB)}},@{Label=”VHDType”;Expression={$_.VHDType}} | Where-Object {($_.VHDType -Match “DynamicallyExpanding” -And $_.Name -NotMatch “{“)}

Leave a Reply

Your email address will not be published. Required fields are marked *