How to calculate total size of a Document library using Powershell in SharePoint 2013/2010/2016?`

Hello SharePointers,

Below are the script to find the actual size of documents in document library using Powershell.

foreach ($web in $site.AllWebs)
foreach ($list in $web.Lists)

if($list.BaseTemplate -eq “DocumentLibrary”)
$itemSize = 0
foreach ($item in $list.items)
$itemSize += ($item.file).length
$itemSize= [Math]::Round(($itemSize/1MB),2)
Write-Host $itemSize “MB ”
Write-Host Size :” “($DocLibSize/1024) “GB”
Write-Host $count

Happy SharePointing Folks 🙂

Leave a Reply

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