PowerCli: Finding amount of GB used by VMs in a folder/vApp/datacenter
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 <name of folder/vApp/datacenter> | foreach {Get-HardDisk -VM $_.name} | Measure-Object CapacityGB -Sum That will give an output that looks something like this: Meaning, in this case, that the folder named “Templates” has 2 VMs occupying 140GB of disk space You can also get a list per vm with this one-liner: get-vm -Location <folder> | select name,@{Name=”Size”;Expression={(Get-HardDisk -VM $_.name | Measure-Object CapacityGB -sum).Sum}}