SharePoint SubSite Size Storage Report

SharePoint 2010 offers nice storage reports with sub-sites. Go to: Site actions > Site Collection Administration >  Storage Metrics to determine the size of SharePoint subsite

sharepoint 2010 subsite size

Get SharePoint Subsite Size with PowerShell:

how to check SharePoint subsite size? We Can use PowerShell to get subsite size. Here is the PowerShell script to get SharePoint subsite size: (works in both SharePoint 2007 and SharePoint 2010)

#Get Size of all Sub-sites in a Site Collection
[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")

# Function to calculate folder size
Function CalculateFolderSize($Folder)
{
    [long]$FolderSize = 0
 
    foreach ($File in $Folder.Files)
    {
        #Get File Size
        $FolderSize += $file.TotalLength;
   
        #Get the Versions Size
        foreach ($FileVersion in $File.Versions)
        {
            $FolderSize += $FileVersion.Size
        }
    }
    #Iterate through all subfolders
    foreach ($SubFolder in $Folder.SubFolders)
    {
        #Call the function recursively
        $FolderSize += CalculateFolderSize $SubFolder
    }
    return $FolderSize
}

 
$SiteURL = "http://sharepoint.company.com/"
$Site = new-object Microsoft.SharePoint.SPSite($SiteURL)
 
foreach($Web in $Site.AllWebs)
{ 
	#Call function to calculate Folder Size
	[long]$WebSize = CalculateFolderSize($Web.RootFolder)

	#Get Recycle Bin Size
	foreach($RecycleBinItem in $Web.RecycleBin)
	{
	   $WebSize += $RecycleBinItem.Size
	}

	$Size = [Math]::Round($WebSize/1MB, 2)
	Write-Host  $web.Url ":`t" $Size "MB"

	#Dispose the object
	$web.dispose()
}
Site Storage Analysis: Don’t want to use Tools/Scripts? just Map your site collection to a Network drive, Use Disk space analyzing tool (jDiskReport, WinDirStat are good choices) to get insights on which site/library eating space!

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!

2 thoughts on “SharePoint SubSite Size Storage Report

  • June 18, 2013 at 8:22 PM

    $Size = [Math]::Round($WebSize/1MB, 2)
    Write-Host $web.Url “:`t” $Size “MB” “:`t” $web.LastItemModifiedDate
    $s = $web.Url +”: “+ $Size +”MB ” +” #” + $web.LastItemModifiedDate
    write-output $s >>get-site-space.txt

    Reply
  • May 22, 2013 at 7:30 PM

    I would like to make this script formatted and email it to my SharePoint team. Can you help code this for me since I have no development experience?

    Reply

Leave a Reply