In this article, I am going to write powershell script to find all lists and libraries in a SharePoint farm server. The following powershell script export all lists from a SharePoint web application to csv file. You need to replace your own web application url.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | Add-PSSnapin Microsoft.SharePoint.PowerShell # get all the site collections $SiteCollections = $SPwebApp .Sites $SiteCollections | ForEach-Object { # get the all sub sites of site collection $SubSites = $_ .AllWebs $SubSites | ForEach-Object { $Site = $_ # get all lists from site $lists = $Site .Lists | Where-Object { $_ .BaseType -eq 'GenericList' } $lists | ForEach-Object { New-Object -TypeName PSObject -Property @{ ListName = $_ .Title SiteName = $Site .Title SiteUrl = $Site .Url }}}}| Export-CSV "C:\All-Lists.csv" -NoTypeInformation -Encoding UTF8 |
Get all Document Libraries in a SharePoint web application
The below powershell script find and export all the document libraries from a SharePoint web application to csv file. You just need to change the BaseType filter in the above query to get document libraries.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue # get all the site collections $SiteCollections = $SPwebApp .Sites $SiteCollections | ForEach-Object { # get the all sub sites of site collection $SubSites = $_ .AllWebs $SubSites | ForEach-Object { $Site = $_ # get all document Libraries from site $lists = $Site .Lists | Where-Object { $_ .BaseType -eq 'DocumentLibrary' } $lists | ForEach-Object { New-Object -TypeName PSObject -Property @{ LibraryName = $_ .Title SiteName = $Site .Title SiteUrl = $Site .Url }}}}| Export-CSV "C:\All-Libraries.csv" -NoTypeInformation -Encoding UTF8 |
Advertisement