So, here goes:
1 2 3 4 5 6 7 |
Connect-VIServer vcenter.pbnet.local Get-VM | ForEach { $vm = $_ Get-harddisk -VM $_ | Select-Object -Property Parent, Name, StorageFormat, CapacityGB, @{N='OS Total Free Space GB of all partitions combined'; E={ [math]::round((Get-VMGuest $vm | ForEach-Object { ($_.Disks) } | Measure-Object -property FreeSpaceGB -sum).Sum)}} } | Export-Csv C:\Temp\vmstorage.csv |
if you want to output to the screen, you can do something like:
1 2 3 4 5 6 7 |
Connect-VIServer vcenter.pbnet.local Get-VM | ForEach { $vm = $_ Get-harddisk -VM $_ | Select-Object -Property Parent, Name, StorageFormat, CapacityGB, @{N='OS Total Free Space GB of all partitions combined'; E={ [math]::round((Get-VMGuest $vm | ForEach-Object { ($_.Disks) } | Measure-Object -property FreeSpaceGB -sum).Sum)}} } | Ft -AutoSize |
and the results will be similar to the ones below:
Enjoy!
Leave a Reply