I'm trying to get the file size of all documents - i.e. pdf, word, xls, etc. I would like to exclude pages, but it's of a minor importance. I have tried the powershell solution in https://www.nothingbutsharepoint.com/sites/itpro/pages/count-and-size-of-all-your-documents-in-sharepoint-2010.aspx , but it returns zero.

Any solutions?


You can do it using below script

[System.Reflection.Assembly]::Load(“Microsoft.SharePoint, Version=,             Culture=neutral, PublicKeyToken=71e9bce111e9429c”)
[System.Reflection.Assembly]::Load(“Microsoft.SharePoint.Portal, Version=,   Culture=neutral, PublicKeyToken=71e9bce111e9429c”)

Add-PSSnapin Microsoft.SharePoint.PowerShell -erroraction SilentlyContinue

$siteURL = "Sitename" 
$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: "+$web.Title+", Library Name: "+$list.Title+", Size: "+[Math]::Round(($listSize/1KB),2)+"KB"     

how to know Exact Document Library size

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.