Hey, what do you know, an actual update. I might eventually get good at this whole “blogging” thing.
I had need this morning to collect the disk size from all of the guest VMs running in our environment, to create seed disks for VMware SRM. There was one that got close, it listed each VM and disk separately (courtesy of http://www.virtu-al.net/2009/03/25/vi-toolkit-one-liner-vm-guest-disk-sizes/):
ForEach ($VM in Get-VM ){($VM.Extensiondata.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)}})}
However this won’t let you export to CSV if you are so inclined. There’s a post in the VMware communities that got me what I needed, which is a listing of how large the disks are for each VM:
Get-VM | Select-Object Name,@{n="HardDiskSizeGB"; e={(Get-HardDisk -VM $_ | Measure-Object -Sum CapacityGB).Sum}}
You can then pipe that through Export-CSV and away we go!