diff --git a/src/cmd/purge/scripts/onedrivePurge.ps1 b/src/cmd/purge/scripts/onedrivePurge.ps1 index 4204d5596..b006b1be3 100644 --- a/src/cmd/purge/scripts/onedrivePurge.ps1 +++ b/src/cmd/purge/scripts/onedrivePurge.ps1 @@ -182,6 +182,14 @@ function Delete-LibraryByPrefix { if ($PSCmdlet.ShouldProcess("Name: " + $l.Title + "Remove folder")) { Write-Host "Deleting list: "$l.Title try { + $listInfo = Get-PnPList -Identity $l.Id -Fields Hidden + + # Check if the 'hidden' property is true + if ($listInfo.Hidden) { + Write-Host "List: $($l.Title) is hidden. Skipping..." + continue + } + Remove-PnPList -Identity $l.Id -Force } catch [ System.Management.Automation.ItemNotFoundException ] {