SharePoint Site Detailed Storage Report using PowerShell

Requirement: Generate a detailed report on all list and library sizes of a SharePoint site.

detailed site storage report in sharepoint using powershell

Solution: PowerShell script! Here is the PowerShell script to generate detailed storage information with listing all list and library sizes.

#Get Size of all lists and libraries in a SharePoint Site

#Get-SPWeb cmdlet for MOSS 2007
Function global:Get-SPWeb($url)
  $site= New-Object Microsoft.SharePoint.SPSite($url)
        if($site -ne $null)
    return $web
#Function to Get Storage Metrics for a list/library 
Function GetStorageMetrics($Folder)
    #Get the size of each file in the folder
    foreach ($File in $Folder.Files)
        #Get File Size
        $FileSize = $File.TotalLength
        #Get the Versions Size
        foreach ($FileVersion in $File.Versions)
            $VersionSize += $FileVersion.Size
        $TotalSize += $VersionSize+ $FileSize  

      #Get Files in Sub Folders
        foreach ($SubFolder in $Folder.SubFolders)
         if($SubFolder.Name -ne "Forms") #Leave "Forms" Folder which has List default Aspx Pages.
     #Call the function recursively for the subfolders
                $TotalSize += GetStorageMetrics($SubFolder)          
        #Return the object
     return $TotalSize

#Set Site URL  variable
$WebURL = ""
#Get the Web
$Web = Get-SPWeb $WebURL

#Array to hold Storage data for all lists and libraries
$StorageDataCollection = @() 

foreach($List in $Web.Lists)
    #Leave the Hidden Lists and exclude certain Libraries
    if($List.Hidden -eq $false)
        #Write-host "Procesing list:" $list.title
        #Call the function to get library's Size relatedMetrics
        $LibrarySize = GetStorageMetrics($List.RootFolder)
        #Create an object to hold storage data
        $StorageDataResult = New-Object PSObject
        #Add other details of the list 
        $StorageDataResult | Add-Member -type NoteProperty -name "List/Library Name" -value $List.Title
        $StorageDataResult | Add-Member -type NoteProperty -name "Item/File Count" -value $List.ItemCount
        $StorageDataResult | Add-Member -type NoteProperty -name "Created by" -value $List.Author
        $StorageDataResult | Add-Member -type NoteProperty -name "Created on" -value $List.Created
        $StorageDataResult | Add-Member -type NoteProperty -name "Last Modified" -value $List.LastItemModifiedDate
        $StorageDataResult | Add-Member -type NoteProperty -name "URL" -value $List.DefaultViewUrl
        #Add storage related Data
        $StorageDataResult | Add-Member -type NoteProperty -name "Total Size (KB)" -value ([Math]::Round(($LibrarySize/1KB),2))

        #Add object to an array
        $StorageDataCollection += $StorageDataResult        

#Get Recycle bin size
foreach($RecycleBinItem in $Web.RecycleBin)
           $RecyclebinSize += $RecycleBinItem.Size
#Get the Total size of the library
$TotalSiteSize = ($StorageDataCollection | Measure-Object 'Total Size (KB)' -Sum | Select -expand Sum)

Write-host "Total Lists/Libraries Size in MB: "([Math]::Round(($TotalSiteSize/1KB),2))
write-host "Recycle bin Size in MB:" ([Math]::Round(($RecyclebinSize/1MB),2))
#Add recycle bin size
Write-host "Total site Size in MB: "([Math]::Round(($TotalSiteSize/1KB)+($RecyclebinSize/1MB),2))
write-host "Total Number of Lists/Libraries in the Site:" $Web.Lists.Count 

#export the detailed storage Info the CSV file
$StorageDataCollection | sort-object "Total Size" -descending | Export-csv "SiteStroageRpt.csv" -notypeinformation
Write-host "Site Storage Report has been generated!"

This script generates the report in CSV format. Here is a snapshot after exporting to Excel:

sharepoint site storage report

It also gives the total size of lists, libraries and size of the recycle bin.

Salaudeen Rajack

Salaudeen Rajack is a SharePoint Architect with Two decades of SharePoint Experience. He loves sharing his knowledge and experiences with the SharePoint community, through his real-world articles!

5 thoughts on “SharePoint Site Detailed Storage Report using PowerShell

  • June 10, 2021 at 8:42 PM

    Sirve para SharePoint Online

  • April 14, 2016 at 12:24 PM

    HI Brother…Is this script works for Sharpoint 2013

  • April 14, 2016 at 12:26 PM

    Got this error After Executing above script

    The term ‘void][System.Reflection.Assembly]::LoadWithPartialName’ is not recognized as the name of a cmdlet, function, script file,
    or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

    • April 14, 2016 at 1:42 PM

      Sridhar, This should work in SharePoint 2013 as well. If you face any trouble, Remove lines between #1 to #13 and add “Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue ” as the first line in your script! Make sure you are running it from any SharePoint APP/WFE Server, Logged in as a Farm Administrator.

  • April 14, 2016 at 12:25 PM

    I tried on Sharepoint 2013..Got error at first Step [void][System.Reflection.Assembly]::LoadWithPartialName(“Microsoft.SharePoint”).

    please help me on this


Leave a Reply