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
- 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.