Sometimes it can be useful to know how much space the VMs in a specific folder (or vApp/datacenter) is occupying. For example if you are a hosting provider of some sort and need to know how much space a customer is using.

It’s a simple one-liner!

get-vm -Location <folder> | select name,@{Name="Size";Expression={(Get-HardDisk -VM $_.name |
Measure-Object CapacityGB -sum).Sum}}