I have seen several examples of generating a report that list the CapacityTB and FreeSpaceTB for a individual Datastores within a DataStoreCluster, but I cannot determine how to just generate:
1. The total CapacityTB of a data store cluster
2. The total FreeSpaceTB of a data store cluster
3. Determine a Provisioned % of a data store cluster, e.g FreeSpaceTB / CapacityTB
I had been using an example that Lucd posted and lightly modified:
foreach ($vc in $VIServer) {
Get-DatastoreCluster -Server $vc |
Select @{N = 'vCenter'; E = {$vc.Name}},
@{N = 'Datacenter'; E = {(Get-Datastore -RelatedObject $_ | select -First 1).Datacenter.Name}},
@{N = 'DSC'; E = {"some DataStoreCluster"}},
CapacityGB,
@{N = 'FreespaceTB'; E = {[math]::Round($_.FreespaceTB, 2)}},
@{N = 'Freespace%'; E = {[math]::Round($_.FreespaceTB / $_.CapacityTB * 100, 1)}},
@{N = 'ProvisionedSpaceTB'; E = {
[math]::Round(($_.ExtensionData.Summary.Capacity - $_.Extensiondata.Summary.FreeSpace + $_.ExtensionData.Summary.Uncommitted) / 1TB, 2)}
},
@{N = 'UnCommittedTB'; E = {[math]::Round($_.ExtensionData.Summary.Uncommitted / 1TB, 2)}},
@{N = 'VM'; E = {((Get-View -Id $_.ExtensionData.ChildEntity).VM.Count | Measure-Object -Sum).Sum}}
}
But it only returns individual DataStores, when I what I really want is to see total for the DataStoreCluster.
I would really love to just limit it to the DataStoreClusters within a specific Cluster of the DataCenter. I'm exhausted my very limited PowerShell skills.
This has been simplified with Get-DatastoreCluster cmdlet.
Please execute below
Not sure why you would only see datastores being returned, the snippet uses Get-DatastoreCluster.
Fixed a couple of inconsistencies and added the requested properties, this should do the trick.
{
Get-DatastoreCluster -Server $vc |
Select-Object @{N = 'vCenter'; E = { $vc.Name } },
@{N = 'Datacenter'; E = { (Get-Datastore -RelatedObject $_ | Select-Object -First 1).Datacenter.Name } },
@{N = 'DSC'; E = { "some DataStoreCluster" } },
@{N = 'CapacityTB'; E = { $_.CapacityGB / 1KB } },
@{N = 'FreespaceTB'; E = { [math]::Round($_.FreespaceGB / 1KB, 2) } },
@{N = 'Freespace%'; E = { [math]::Round($_.FreespaceGB / $_.CapacityGB * 100, 1) } },
@{N = 'ProvisionedSpaceTB'; E = {
[math]::Round(($_.ExtensionData.Summary.Capacity - $_.Extensiondata.Summary.FreeSpace + $_.ExtensionData.Summary.Uncommitted) / 1TB, 2) }
},
@{N = 'ProvisionedSpace%'; E = {
[math]::Round((($_.ExtensionData.Summary.Capacity - $_.Extensiondata.Summary.FreeSpace + $_.ExtensionData.Summary.Uncommitted) / 1GB) / $_.CapacityGB * 100, 1) }
},
@{N = 'UnCommittedTB'; E = { [math]::Round($_.ExtensionData.Summary.Uncommitted / 1TB, 2) } },
@{N = 'VM'; E = { ((Get-View -Id $_.ExtensionData.ChildEntity).VM.Count | Measure-Object -Sum).Sum } }
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
This does give me what I need without the additional expression to calculate the % already provisioned, which LucD answer does include. I'm using a combination of both answers, and I really appreciate the responses from both of you.