Looking for Wasted Space inside Virtual Machines

Looking for Wasted Space inside Virtual Machines

Rate This
  • Comments 3

Recently, I tried to update the operating system installed inside of one of my virtual machines.  I quickly received an error message stating that I did not have enough free space available to perform the upgrade.  My immediate thought was that I would need to expand the size of the virtual hard disk – but after a bit of investigation I was surprised to discover that the virtual hard disk had already been expanded.  I just hadn’t expanded the partition to take advantage of it.

Clearly, I had been planning to do this at some other time – and had gotten distracted in the middle of the process.

This made me wonder: do I have any other virtual machines that are sitting on unpartitioned, wasted space?

Luckily, this is an easy question to answer.  You see, the virtual hard disk object that is returned by “Get-VHD” includes a “MinimumSize” property.  This property will tell you how much unpartitioned space is available at the end of the disk.  So the following command:

Get-VM | Get-VMHardDiskDrive | Get-VHD | Select path, @{Name="Free Space (GB)";Expression={"{0:N2}" -f (($_.Size - $_.MinimumSize)/1GB)}}

Will tell you exactly what is going on with your system.  When I ran this on my server:


I discovered that I had two extra virtual machines with wasted space!


Leave a Comment
  • Please add 4 and 2 and type the answer here:
  • Post
  • Some more Kung fu for you!

    Pull a list of cluster server names...

    $servers = (Get-ClusterNode).name

    ... or enter a list however you please

    $servers = "serverA", "serverB"

    And pull the free space data from the them all at once ...

    $servers | % { Get-VM -Computer $_ | Get-VMHardDiskDrive | Get-VHD -ComputerName $_ | Select path, @{Name="Free Space (GB)";Expression={"{0:N2}" -f (($_.Size - $_.MinimumSize)/1GB)}}}

    Thanks for sharing!


  • Ben,

    you Minecraft server is priceless ;)

  • Justin-Bennett -


    marcinbojko -

    As far as my family is concerned, that is one of the most important servers I run!



Page 1 of 1 (3 items)