Skip to content

Instantly share code, notes, and snippets.

@vaderj
Last active June 12, 2018 15:11
Show Gist options
  • Save vaderj/23c6ce0f0dad4e70b1b58f825a8a86a5 to your computer and use it in GitHub Desktop.
Save vaderj/23c6ce0f0dad4e70b1b58f825a8a86a5 to your computer and use it in GitHub Desktop.
Powershell - Get size of SharePoint document libray #PowerShell #SharePoint
Add-PSSnapin Microsoft.SharePoint.PowerShell
$siteURL = "YourSitename"
$site = new-object Microsoft.SharePoint.SPSite($siteURL)
foreach ($web in $site.AllWebs)
{
foreach ($list in $web.Lists)
{
if($list.BaseType -eq "DocumentLibrary")
{
$listSize = 0
foreach ($item in $list.items)
{
$listSize += ($item.file).length
}
"Web Name: "+$web.Title+", Library Name: "+$list.Title+", Size: "+[Math]::Round(($listSize/1KB),2)+"KB"
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment