PowerShell One Liner for Count of all Documents in SharePoint 2010 Farm

Last week I had a client reach out to me, asking for a count of all documents in their SharePoint 2010 internal farm. They were planning on implementing Metalogix StoragePoint and were working on estimates for the deployment.
After a bit of work with PowerShell, I was able to throw a single line of PowerShell that sum’s the entire environment for me.

Get-SPSite -Limit All | Get-SPWeb -Limit All | % { $_.Lists} | ? { $_ -is [Microsoft.SharePoint.SPDocumentLibrary] } | % { $total+= $_.ItemCount} ; $total
Love it? Share it!

4 thoughts on “PowerShell One Liner for Count of all Documents in SharePoint 2010 Farm”

  1. Does this include custom lists or only document library files? I need to be sure that I am only getting library files and not form list items.

  2. Hi , I was wondering if it will count all the documents in the document library and also within the folder inside the document library

    1. Raj, this is the ItemCount that the SharePoint API is presenting, this should include all items inside of it including the items within the folders. I do not have a SharePoint farm available to test this in anymore though.

Leave a Reply to MattG Cancel Reply

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