Beautilful! I added another filter and the query takes about 7 seconds instead of the 1/2 second with "get-datastore *", Is there anyway I can optimize the query?
Get-Datastore sg*| Get-View |where {$_.Name -match "lun|template"} | Select -ExpandProperty Summary | Select Name,
@{N="Capacity"; E={[Math]::Round($_.Capacity/1GB,0) }},
@{N="Provisioned"; E={[Math]::Round(($_.Capacity - $_.FreeSpace + $_.Uncommitted)/1GB,0) }},
@{N="ProvFreeSpace"; E={[Math]::Round(($_.FreeSpace - $_.Uncommitted)/1GB,0) }},
@{N="FreeSpace"; E={[Math]::Round($_.FreeSpace/1GB,0) }}| Sort-Object ProvFreeSpace -descending|
format-table -AutoSize -Wrap
I noticed if the disks type are mix of thick /thin, the calculations for the provisioned would be off.
get-harddisk *template|select StorageFormat,persistence,disktype,CapacityKB|format-tableStorageFormat Persistence DiskType CapacityKB
------------- ----------- -------- ----------
Thick Persistent Flat 41943040
Thin Persistent Flat 20971520
Thin Persistent Flat 26214400
Thin Persistent Flat 52428800
Name Capacity Provisioned ProvFreeSpace FreeSpace
---- -------- ----------- ------------- ---------
vtemplate 200 203 -3 140