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:
Scenario
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:
Code
$cred = Get-Credential Connect-PnPOnline -Url "https://mytenant.sharepoint.com/sites/demo" -Credentials $cred #the following is required to load the corresponding list templates for each list/library $ctx = Get-PnPContext $templates = (Get-PnPWeb).ListTemplates $ctx.Load($templates) $ctx.ExecuteQuery() 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
And here’s the output from the script:
Office 365 Advent Calendar – 14 Exporting SharePoint Online List/Library Details https://t.co/PuIXEvN8iB #office365adventcalendar