1 Reply Latest reply on Jan 22, 2020 12:38 PM by LucD

    Capture folder size of Appvolumes on Vsan

    Justin_Y Novice

      I found a few scripts and this one seems to be close. The problem is the sizes are not adding up for instance the writable_templates folder has 3 80mb tempates so it shouldn't be 30gb. I think I am seeing what the inflated Thick provision size would be but I would like to see the size on disk for all of our appvolumes. Mainly concerned about the Apps folder to have a quick way to get how much of the VSAN this is using.


      $datastores = Get-Datastore


      foreach($ds in $datastores){



          New-PSDrive -Location $ds -Name DS -PSProvider VimDatastore -Root "\" > $null


          Get-ChildItem -Path DS:\cloudvolumes | where{$_.ItemType -eq 'Folder' -and $_.Name -notmatch '^\.|^vmk|^esxconsole|tmp'} | %{


              New-Object PSObject -Property @{


                  Datastore = $ds.Name


                  Folder = $_.Name


                  SizeGB = [math]::Round((Get-ChildItem -Path "DS:\cloudvolumes\$($_.Name)" | Measure-Object -Property Length -Sum | select -ExpandProperty Sum)/1GB)



          Remove-PSDrive -Name DS -Confirm:$false


      Datastore               SizeGB      Folder    

      ---------                    ------           ------         

      DS01                    30      writable_templates

      DS01                     0      writable                 

      DS01                   745      apps               

      DS01                   230      apps_templates

        • 1. Re: Capture folder size of Appvolumes on Vsan
          LucD Guru
          User ModeratorsCommunity WarriorsvExpert

          The Length value is normally the actual size of the file, not the overcommit value.

          Are you sure there are no snapshots or other files in the folders?

          Can you do a straight-forward list of the files in the folders, and check their value in Length.
          The VMDKs that are Thin should show the actual size on the datastore


          $ds = Get-Datastore -Name MyDS

          New-PSDrive -Location $ds -Name DS -PSProvider VimDatastore -Root "\" > $null

          Get-ChildItem -Path DS:\ | where{$_.ItemType -eq 'Folder' -and $_.Name -notmatch '^\.|^vmk|^esxconsole|tmp'} | %{

             Write-Host -ForegroundColor green "-- Folder -- $($_.FullName)"

             Get-ChildItem -Path "DS:\$($_.Name)" | where{$_.Name -notmatch '^\.'} | Select Name,Length


          Remove-PSDrive -Name DS -Confirm:$false

          Blog: http://lucd.info | Twitter: @LucD22 | PowerCLI Reference co-author: http://tinyurl.com/hkn4glz