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
Steps
- Open your SharePoint Management Shell.
- Copy the below code.
- Run this one.
Code
Load the below required libraries before we execute the code.
- [System.Reflection.Assembly]::Load("Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c")
- [System.Reflection.Assembly]::Load("Microsoft.SharePoint.Portal, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c")
- [System.Reflection.Assembly]::Load("Microsoft.SharePoint.Publishing, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c")
- [System.Reflection.Assembly]::Load("System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")
- function Get-DocReport([string]$siteUrl) {
- $SPsite = New-Object Microsoft.SharePoint.SPSite $siteUrl
- foreach ($web in $SPsite.AllWebs) {
- foreach ($list in $web.Lists) {
- if ($list.BaseType -eq "DocumentLibrary") {
- continue
- }
- foreach ($item in $list.Items) {
- $data = @{
- "Site" = $site.Url
- "Web" = $web.Url
- "list" = $list.Title
- "Item ID" = $item.ID
- "Item Title" = $item.Title
- "Created By" = $item["Author"]
- "Modified By" = $item["Editor"]
- "File Size (MB)" = $item.File.Length/1MB
- }
- New-Object PSObject -Property $data
- }
- }
- $web.Dispose();
- }
- $site.Dispose()
- }
- Get-DocReport "http://gowthamr.sharepoint.com" | Export-Csv -NoTypeInformation -Path "D:\OuputFolder\DetailReport.csv"
That's it. We are now good to go.

Mahesh ThokalaPosted Dec 13, 2020, 10:10 AM
New-Object : Exception calling ".ctor" with "1" argument(s): "The HTTP service located at http://localhost:32843/SecurityTokenServiceApplication/securitytoken.svc is unavailable. This could be because the service is too busy or because no endpoint was found listening at the specified address. Please ensure that the address is correct and try accessing the service again later." At C:\Users\21292\Desktop\Generate Document Info Report.ps1:7 char:11 + $SPsite = New-Object Microsoft.SharePoint.SPSite $siteUrl + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (:) [New-Object], MethodInvocationException + FullyQualifiedErrorId : ConstructorInvokedThrowException,Microsoft.PowerShell.Commands.NewObjectCommand You cannot call a method on a null-valued expression. At C:\Users\21292\Desktop\Generate Document Info Report.ps1:30 char:1 + $site.Dispose() + ~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (:)
Mahesh ThokalaPosted Dec 13, 2020, 10:09 AM
Thanks for your post. i AM GETTING ERROR. Could you please help me on the same.
Vinayak RamPosted Jul 17, 2017, 3:28 AM
How to create a powershell script and generate a report sitecollcetion url, site name, library name, document name, document url,major version count, minor version count on all documents that have versions greaterthan 10 in sharepoint 2013