Before a migration or a cleanup, the first thing I ask for is an inventory: which lists and libraries does this site actually have, how big are they, and which ones nobody has touched in months? Clicking through Site contents works for one site, but not for ten.
PnP PowerShell answers that in a single line. Here’s how I get every list and library on a site, separate libraries from lists, skip the system ones, export the result to CSV, and run the same report across several sites. Every script ran read-only against my own Microsoft 365 tenant in PowerShell 7, and the screenshots are the real output.
Quick answer: Connect with Connect-PnPOnline -Url https://contoso.sharepoint.com/sites/Sales -ClientId <app id> -Interactive, then run Get-PnPList. Add | Where-Object { -not $_.Hidden } to drop hidden system lists, and filter on BaseType -eq "DocumentLibrary" to keep only libraries.
Get all lists and libraries with Get-PnPList
Run without parameters, Get-PnPList returns every list and library in the site you’re connected to. You’ll need PnP PowerShell 3.x in PowerShell 7 and your own Entra ID app; installing PnP PowerShell covers the setup. My test site returned 26 lists, but 12 of them were hidden galleries and catalogs, so I filter those out:

BaseType tells you whether it’s a list (GenericList) or a library (DocumentLibrary). ItemCount is the stored total, so it’s instant even on big lists, and RootFolder.ServerRelativeUrl gives the real URL. Look at the archive lists: a renamed list keeps its original URL, so report both columns.
| BaseTemplate | What it is |
|---|---|
| 100 | Custom list (including lists made in Microsoft Lists) |
| 101 | Document library, also Site Assets, Style Library, Form Templates |
| 104 / 106 / 107 | Announcements / Calendar (Events) / Tasks |
| 109 | Picture library |
| 119 | Site Pages |
Get only document libraries or only lists
Filtering on BaseTemplate -eq 101 is the common trick, but it lets Site Assets and Style Library through and misses Site Pages. I filter on BaseType instead and drop system libraries with IsSystemList, which you load through -Includes:
# Skip hidden and system lists (Site Pages, Site Assets, Style Library, Form Templates)
$lists = Get-PnPList -Includes IsSystemList | Where-Object { -not $_.Hidden -and -not $_.IsSystemList }
$lists | Where-Object BaseType -eq "DocumentLibrary" |
Select-Object Title, ItemCount,
@{ N = "LastModified"; E = { $_.LastItemUserModifiedDate.ToString("MM/dd/yyyy") } } |
Format-Table -AutoSize
$lists | Where-Object BaseType -ne "DocumentLibrary" |
Select-Object Title, BaseTemplate, ItemCount | Format-Table -AutoSize

Only the two real libraries are left, with their last modified date, which is a quick way to spot abandoned content. Need folder sizes too? See how to get a SharePoint document library size.
Load extra properties with -Includes
Get-PnPList loads the common properties, and RootFolder came back ready in my runs. Others, such as HasUniqueRoleAssignments (broken permission inheritance) and IsSystemList, stay empty until you name them: Get-PnPList -Includes HasUniqueRoleAssignments, IsSystemList. To go one level deeper, the list column details script lists every column of a list.
Export the list inventory to CSV
Pipe the same objects to Export-Csv. Calculated properties flatten the URL and format the date, so the file opens cleanly in Excel:
$lists | Select-Object Title, BaseType, BaseTemplate, ItemCount,
@{ N = "Url"; E = { $_.RootFolder.ServerRelativeUrl } },
@{ N = "LastModified"; E = { $_.LastItemUserModifiedDate.ToString("MM/dd/yyyy") } } |
Export-Csv -Path "C:\Reports\Sales-lists.csv" -NoTypeInformation
My run exported ten rows. If you also need the files themselves, downloading all files from SharePoint uses the same connection.
Get lists and libraries from all sites in the tenant
For more than one site, connect to the SharePoint admin center (you need the SharePoint Administrator role), get the sites with Get-PnPTenantSite, and open a connection per site with -ReturnConnection. I limited my demo to two sites; drop the Where-Object to scan everything:
$clientId = "<your app's client ID>"
$admin = Connect-PnPOnline -Url "https://contoso-admin.sharepoint.com" -ClientId $clientId `
-Interactive -ReturnConnection
$sites = Get-PnPTenantSite -Connection $admin | Where-Object { $_.Url -match "/sites/(Sales|Marketing)$" }
$report = foreach ($site in $sites) {
$conn = Connect-PnPOnline -Url $site.Url -ClientId $clientId -Interactive -ReturnConnection
Get-PnPList -Connection $conn -Includes IsSystemList |
Where-Object { -not $_.Hidden -and -not $_.IsSystemList } |
ForEach-Object {
[pscustomobject]@{
Site = $site.Title; Title = $_.Title; Type = $_.BaseType; Items = $_.ItemCount
}
}
}
$report | Format-Table -AutoSize

OneDrive sites are skipped unless you add -IncludeOneDriveSites, and -Template SITEPAGEPUBLISHING#0 narrows the scan to communication sites. With hundreds of sites, use certificate (app-only) authentication so the loop doesn’t prompt for each one.
Common errors and fixes
- “A parameter cannot be found that matches parameter name ‘Web'”:
Get-PnPListin PnP PowerShell 3.x has no-Webparameter. Connect to the subsite URL instead. - Empty HasUniqueRoleAssignments or IsSystemList: the property wasn’t loaded. Add it to
-Includes. - Access denied on Get-PnPTenantSite: the account isn’t a SharePoint administrator, or you’re connected to a regular site instead of the admin URL.
- A list is missing: it’s probably hidden. Remove the
Hiddenfilter, or search by URL withGet-PnPList -Identity Lists/Orders.
Once you know what’s on the site, you can act on it. Creating and deleting a document library with PowerShell and the PnP PowerShell scripts for SharePoint collection are good next steps.
If you’re auditing SharePoint sites with PowerShell, these guides help too:
Frequently Asked Questions
How do I get all document libraries in SharePoint Online using PnP PowerShell?
Run Get-PnPList and keep the items where BaseType equals DocumentLibrary and Hidden is false. Add -Includes IsSystemList to skip Site Pages and Site Assets. See the Get-PnPList reference.
What is the difference between BaseType and BaseTemplate?
BaseType is the broad kind: GenericList for lists and DocumentLibrary for libraries. BaseTemplate is the exact template number, such as 100 for a custom list, 101 for a document library and 119 for Site Pages.
How do I get lists from a subsite with PnP PowerShell?
Connect-PnPOnline to the subsite’s own URL and run Get-PnPList. Current PnP PowerShell versions don’t have a -Web parameter on Get-PnPList.
Can I get all lists and libraries from every site in the tenant?
Yes. Connect to the admin center, loop through Get-PnPTenantSite, and run Get-PnPList with a per-site -Connection. The Get-PnPTenantSite reference lists the filter options.
Does ItemCount slow down the script on large lists?
No. ItemCount is a stored property of the list, so Get-PnPList returns it without reading the items, even when a list holds more than 5,000 items.

Hey! I’m Bijay Kumar, founder of SPGuides.com and a Microsoft Business Applications MVP (Power Automate, Power Apps). I launched this site in 2020 because I truly enjoy working with SharePoint, Power Platform, and SharePoint Framework (SPFx), and wanted to share that passion through step-by-step tutorials, guides, and training videos. My mission is to help you learn these technologies so you can utilize SharePoint, enhance productivity, and potentially build business solutions along the way.