SharePoint 2013 - Get All Document Library Detailed report using Powershell

This script will help you to retrieve all the document libraries in Site Collection and will give details about the library using simple method.

Steps
  1. Open your SharePoint Management Shell.
  2. Copy the below code.
  3. Run this one.
Code

Load the below required libraries before we execute the code.
  1. [System.Reflection.Assembly]::Load("Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c")  
  2. [System.Reflection.Assembly]::Load("Microsoft.SharePoint.Portal, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c")  
  3. [System.Reflection.Assembly]::Load("Microsoft.SharePoint.Publishing, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c")  
  4. [System.Reflection.Assembly]::Load("System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")  
  1. function Get-DocReport([string]$siteUrl) {  
  2. $SPsite = New-Object Microsoft.SharePoint.SPSite $siteUrl  
  3. foreach ($web in $SPsite.AllWebs) {  
  4. foreach ($list in $web.Lists) {  
  5. if ($list.BaseType -eq "DocumentLibrary") {  
  6. continue  
  7. }  
  8.   
  9. foreach ($item in $list.Items) {  
  10. $data = @{  
  11. "Site" = $site.Url  
  12. "Web" = $web.Url  
  13. "list" = $list.Title  
  14. "Item ID" = $item.ID  
  15. "Item Title" = $item.Title  
  16. "Created By" = $item["Author"]  
  17. "Modified By" = $item["Editor"]  
  18. "File Size (MB)" = $item.File.Length/1MB  
  19. }  
  20. New-Object PSObject -Property $data  
  21. }  
  22. }  
  23. $web.Dispose();  
  24. }  
  25. $site.Dispose()  
  26. }  
  27.   
  28.   
  29. Get-DocReport "http://gowthamr.sharepoint.com" | Export-Csv -NoTypeInformation -Path "D:\OuputFolder\DetailReport.csv"   
That's it.  We are now good to go.