Nov 15 2021 04:10 PM
I need a help with PowerShell to generate a report with list of all the Libraries With No Retention Label from the SharePoint tenant Does anyone have a script
Is there any way to loop this to all the sites & library's in the tenant
Get-PnPLabel [-List ] [-Raw] [-Connection ] https://github.com/pnp/powershell/blob/dev/documentation/Get-PnPLabel.md
Thank you
Nov 18 2022 01:17 PM - edited Nov 18 2022 01:20 PM
I am setting off to do the same thing, here is what I have for all libraries in a site. You'll just need to add foreach Site in AllSites...
#Parameters
$SiteURL = "https://changeme.sharepoint.com/sites/siteA"
#Connect to PnP Online
Connect-PnPOnline -Url $SiteURL -Interactive
#Get the Root Web
$Web = Get-PnPWeb
#Get all lists
$Lists = Get-PnPList
#exclude system lists
$systemLibs = @("Form Templates","Site Assets", "Site Pages", "Style Library")
foreach ($list in $Lists) {
if ($list.Hidden -eq $true) {
Write-Host " Skipped hidden: " $list.Title -ForegroundColor Gray
} else {
if ($systemLibs.Contains($list.Title)) {
Write-Host " Skipped system lib: " $list.Title -ForegroundColor Gray
} else {
Write-Host $list.Title -ForegroundColor Yellow
Get-PnPLabel -List $list #-ValuesOnly "TagName"
}
}
}
Disconnect-PnPOnline #Friends dont let friends leave connections open