A Simple One-liner today but it shows you how to add information along the pipe line to enable new properties which can be formed using other cmdlets or simple math statements on existing properties:

This one-liner will give you the VM disk or partition sizes for each of your VMs:

ForEach ($VM in (Get-VM |Get-View)){($VM.Guest.Disk |Select @{N=Name;E={$VM.Name}},DiskPath, @{N=Capacity(MB);E={[math]::Round($_.Capacity/ 1MB)}}, @{N=Free Space(MB);E={[math]::Round($_.FreeSpace / 1MB)}}, @{N=Free Space %;E={[math]::Round(((100 * ($_.FreeSpace))/ ($_.Capacity)),0)}}) | Format-Table}

 

Output:

image