QuickTip: Get Datastore Capacity with a PowerCLI One-Liner

Hey! I wanted to throw this one quickly your way.

So in vSphere you can see the general status of a datastore.


Which gives you all the information, but only shows one datastore at a time.

You can look at all the datastores at one time, but don’t get all the capacity info…


So naturally if you want all the information you need to take a look at powershell.

So here is the one-liner to get all the info you want

get-datastore | select-object name,@{Label=”FreespaceGB”;E={“{0:n2}” -f ($_.FreespaceGB)}}, CapacityGB, @{Label=”Provisioned”;E={“{0:n2}” -f ($_.CapacityGB – $_.FreespaceGB +($_.extensiondata.summary.uncommitted/1GB))}}|sort name


Yes my “one-liner” is really long. One reason it is also longer, is because I am formatting the numbers to two decimal places, which makes it easier to read I think. But if you don’t care about formatting you can use this one….

get-datastore | select-object name, FreespaceGB, CapacityGB, @{Label=”Provisioned”;E={($_.CapacityGB – $_.FreespaceGB +($_.extensiondata.summary.uncommitted/1GB))}}|sort name

Which is a bit shorter… Enjoy!!!

Leave a Reply