Get All List and Libraries Inventory of a SharePoint Site Collection using PowerShell
Requirement: Get All Lists and Libraries Inventory of a SharePoint Site Collection
PowerShell to Get Site Collection Inventory:
Report Output:
Get Inventory for All Site Collections in a Web Application
Before running the script, make sure you add a web application user policy with Full control for the web application.
PowerShell to Get Site Collection Inventory:
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue #Site collection Variable $SiteURL="http://intranet.crescent.com" $ReportOutput="C:\SiteInventory.csv" #Get the site collection $Site = Get-SPSite $SiteURL $ResultData = @() #Ge All Sites of the Site collection Foreach($web in $Site.AllWebs) { Write-host -f Yellow "Processing Site: "$Web.URL #Get all lists - Exclude Hidden System lists $ListCollection = $web.lists | Where-Object { ($_.hidden -eq $false) -and ($_.IsSiteAssetsLibrary -eq $false)} #Iterate through All lists and Libraries ForEach ($List in $ListCollection) { $ResultData+= New-Object PSObject -Property @{ 'Site Title' = $Web.Title 'Site URL' = $Web.URL 'List-Library Name' = $List.Title 'Item Count' = $List.ItemCount 'Created By' = $List.Author.DisplayName 'Last Modified' = $List.LastItemModifiedDate.ToString(); 'List URL' = "$($Web.Url)/$($List.RootFolder.Url)" } } } #Export the data to CSV $ResultData | Export-Csv $ReportOutput -NoTypeInformation Write-host -f Green "Report Generated Successfully at : "$ReportOutput
Report Output:
Get Inventory for All Site Collections in a Web Application
Before running the script, make sure you add a web application user policy with Full control for the web application.
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue #Set Parameters $WebAppURL="http://intranet.sharepoint.com" $ReportOutput="C:\Temp\SiteInventory.csv" #Delete the Output report file if exists If (Test-Path $ReportOutput) { Remove-Item $ReportOutput } #Get all site collections from the web application Get-SPWebApplication $WebAppURL | Get-SPSite -Limit ALL | Get-SPWeb -Limit ALL -PipelineVariable Web | ForEach-Object { Write-host -f Yellow "Processing Site: "$Web.URL #Get all lists - Exclude Hidden System lists $ListCollection = $Web.lists | Where-Object { ($_.hidden -eq $false) -and ($_.IsSiteAssetsLibrary -eq $false)} $ResultData = @() #Iterate through All lists and Libraries ForEach ($List in $ListCollection) { $ResultData+= New-Object PSObject -Property @{ 'Site Title' = $Web.Title 'Site URL' = $Web.URL 'List/Library Name' = $List.Title 'Item Count' = $List.ItemCount 'Created By' = $List.Author.DisplayName 'Last Modified' = $List.LastItemModifiedDate.ToString(); 'List URL' = "$($Web.Url)/$($List.RootFolder.Url)" } } #Append data to CSV $ResultData | Export-Csv $ReportOutput -NoTypeInformation -Append } Write-host -f Green "Report Generated Successfully at : "$ReportOutput
Can you please help me to generate this report in SharePoint Online?
ReplyDeleteHere you go: SharePoint Online PowerShell script to get lists and libraries report
Deletecan we get title only once
DeleteThank you and good work!
ReplyDelete@Sal :Thank you so much for your great contribution to SharePoint folks...because of your script i saved my time..!
ReplyDeleteWill it be able to run the script for number of sites together rather individual.
ReplyDeleteAs an example: if have 200 sits
http://intranet.crescent.com/site/siteA
http://intranet.crescent.com/site/siteB
Sure, Script added to get list inventory from all sites in a web application.
DeleteThank you for the reply. Unfortunately it giving me list of libraries in root level not the site level:
Deletehttp://intranet.crescent.com/site/.....
what can be the reason?
Thank you helped me a lot
ReplyDelete