Well, this is a bit embarrassing. Yesterday, for the first time, I didn’t verify if my scheduled blog post got published properly. And yesterday, also for the first time, it didn’t get published. I made a small scheduling mistake (it’s not 2017 yet…), so the 14th December post comes a day late:


From time to time you may need an overview of all lists and libraries in your site together with the number of items in each list/library, and when an item in it was last modified. You can easily see this information from the Site Contents page:

But there are times when this information needs to be available in Excel, which is what I’ll show you today how to retrieve:


$cred = Get-Credential
Connect-PnPOnline -Url "" -Credentials $cred

#the following is required to load the corresponding list templates for each list/library
$ctx = Get-PnPContext
$templates = (Get-PnPWeb).ListTemplates

Get-PnPList | select Title, @{label="Url";Expression={$_.RootFolder.ServerRelativeUrl}},`
@{label="Type";Expression={$bt=$_.BaseTemplate;$templates |`
Where{$_.ListTemplateTypeKind -eq $bt} | foreach{$_.Name}}},`
ItemCount, LastItemModifiedDate | Export-Csv c:\ListInfo.csv

Code on GitHub

And here’s the output from the script:


One thought on “Office 365 Advent Calendar – 14 Exporting SharePoint Online List/Library Details”

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.