3 Replies Latest reply on Apr 9, 2019 8:11 AM by kkhenson

    How to total DataStoreCluster Capacity and FreeSpace not individual DataStores?

    kkhenson Lurker

      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.

        • 1. Re: How to total DataStoreCluster Capacity and FreeSpace not individual DataStores?
          jatinjsk Enthusiast

          This has been simplified with Get-DatastoreCluster cmdlet.

          Please execute below

           

           

          Get-DatastoreCluster |Select-object Name, @{N="CapacityTB";E={[math]::Round($_.CapacityGB/1024,2)}}, @{N="FreeSpaceTB";E={[math]::Round($_.FreeSpaceGB/1024,2)}}
          Thanks,
          Jatin Purohit
          • 2. Re: How to total DataStoreCluster Capacity and FreeSpace not individual DataStores?
            LucD Guru
            User ModeratorsCommunity WarriorsvExpert

            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.

             

            foreach ($vc in $global:DefaultVIServers)

            {

               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 } }

            }

            • 3. Re: How to total DataStoreCluster Capacity and FreeSpace not individual DataStores?
              kkhenson Lurker

              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.