7 Replies Latest reply on Feb 7, 2018 10:30 AM by LucD

    Accessing Total Provisioned Space on Datastore Summary Tab

    TheVMinator Master

      I'm looking at the datastore summary tab for a datastore object in vSphere Client and I see what is on the attached screenshot.

       

      I can't seem to find this property on the object in powerCLI.  (At least for purposes of this specific post) I don't want to try to calculate it myself by adding up the individual VMs but I want to try to access the exact same property using PowerCLI which is being displayed in the attached screenshot.

       

      Where can I find this property?  How do I add it to this script:

       

      get-datastore | select name, freespacegb, [access this property somehow here]

       

      Thanks!

        • 1. Re: Accessing Total Provisioned Space on Datastore Summary Tab
          LucD Guru
          User ModeratorsvExpertCommunity Warriors

          Try like this

           

          Get-Datastore |

          Select Name,CapacityGB,FreespaceGB,

              @{N='ProvisionedGB';E={($_.ExtensionData.Summary.Capacity - $_.ExtensionData.Summary.FreeSpace + $_.ExtensionData.Uncommitted)/1GB}}

          1 person found this helpful
          • 2. Re: Accessing Total Provisioned Space on Datastore Summary Tab
            TheVMinator Master

            Somehow this isn't equal to the "provisioned space" on the datstore tab.  When I run this, it gives me 2028GB, but the provisioned space on the datastore tab is 2.3 TB.

             

            Any ideas?

            • 3. Re: Accessing Total Provisioned Space on Datastore Summary Tab
              LucD Guru
              User ModeratorsCommunity WarriorsvExpert

              I just checked with a couple of my datastores, and the numbers correspond perfectly.

              There must be other data on those datastores that is apparently not taken into account.

              Can you check if Monitor-Performance-Space-By Filetype shows something that could explain the difference you are seeing.

               

              Also note that the numbers you see in the Client are only refreshed on an interval.

              In the Web Client you have a Refresh button to force a recalculation.

              1 person found this helpful
              • 4. Re: Accessing Total Provisioned Space on Datastore Summary Tab
                TheVMinator Master

                OK thanks for the info.  I guess my difficulty is that for everything else I've seen in the GUI, usually there is a way to get it by PowerCLI without too much difficulty.   I was thinking that since "provisioned space" for the entire datastore object was a pretty common thing for people to want to know and see, there must be a PowerCLI way to get it without too much difficulty.

                 

                It could be that other data on the datastore such as array snapshots or some other unusual file types are affecting what I see in the GUI for "provisioned space".  However, even if that were the case, isn't there a way with PowerCLI to just get the same number as what I'm seeing in the GUI?  I can't see how that number could be available in vCenter to be called through the Web Client or the vSphere Client, but it can't be called through PowerCLI.

                 

                Is this a rare, hard to get metric that would need to be accessed programatically a different way than PowerCLI such as with the web services sdk? 

                • 5. Re: Accessing Total Provisioned Space on Datastore Summary Tab
                  LucD Guru
                  User ModeratorsvExpertCommunity Warriors

                  Like I said, for me the values correspond exactly.

                   

                  It would be interesting to know where the differences you see come from.

                  Is Monitor-Performance-Space-By File Type showing correct values in your case?

                   

                  And the recalculation of the numbers can be forced through an API method.

                  Like this (I most of the time see small changes in the numbers after this call).

                   

                  $dsName = 'MyDS'

                   

                  $ds = Get-Datastore -Name $dsName

                  $ds |

                  Select Name,CapacityGB,FreespaceGB,

                      @{N='ProvisionedGB';E={($_.ExtensionData.Summary.Capacity - $_.ExtensionData.Summary.FreeSpace + $_.ExtensionData.Uncommitted)/1GB}}

                   

                  $ds.ExtensionData.RefreshDatastoreStorageInfo()

                   

                  $ds = Get-Datastore -Name $dsName

                  $ds |

                  Select Name,CapacityGB,FreespaceGB,

                      @{N='ProvisionedGB';E={($_.ExtensionData.Summary.Capacity - $_.ExtensionData.Summary.FreeSpace + $_.ExtensionData.Uncommitted)/1GB}}

                   

                   

                  • 6. Re: Accessing Total Provisioned Space on Datastore Summary Tab
                    BigBlueMike Novice
                    vExpert
                    LucD I think you have a typo.LucD I think you have a typo.
                    replace
                    $_.ExtensionData.Uncomitted with $_.ExtensionData.Summary.Uncommitted and then the numbers should add up, at least it did for me
                    LucD, I think you have a typo (two M's).
                     
                    replace
                     
                    $_.ExtensionData.Uncomitted
                     
                    with
                     
                    $_.ExtensionData.Summary.Uncommitted
                     
                    and then the numbers should add up, at least it did for me.
                     
                    replace
                    $_.ExtensionData.Uncomitted with $_.ExtensionData.Summary.Uncommitted and then the numbers should add up, at least it did for me
                    • 7. Re: Accessing Total Provisioned Space on Datastore Summary Tab
                      LucD Guru
                      User ModeratorsCommunity WarriorsvExpert

                      You are correct, well spotted.
                      I updated the code snippets above.