Get The Size of a Document Library

“How large is my Document Library”

This was an odd one to crack. For reporting reasons, our team wanted to track the item count and size growth of a Document Library. Sound easy?

if(-not(Get-PSSnapin | where { $_.Name -eq "Microsoft.SharePoint.PowerShell"}))
{
      Add-PSSnapin Microsoft.SharePoint.PowerShell;
}

$SPsite = Get-SPsite "http://www.sharepointed.com/sites/taco/"

$dataTable = $SPsite.StorageManagementInformation(2,0x11,0,0)
foreach($x in $dataTable.Rows)
{
	if ($x.LeafName -eq "MyTacoLibrary" -and $x.Directory -eq "sites/taco")
		{
			$LibSize = [Math]::Round(($x.Size/1GB),2)
			Write-Host $LibSize
		}
}

Thanks you Jon for guiding this script.

Leave a Reply

Your email address will not be published. Required fields are marked *