From 95dab16f679732c26f99cf16477b94cd40a43342 Mon Sep 17 00:00:00 2001 From: Hitesh Pattanayak <48874082+HiteshRepo@users.noreply.github.com> Date: Sun, 24 Dec 2023 10:25:10 +0530 Subject: [PATCH] skip cleanup of hidden list (#4934) skips cleanup of hidden list considering them system generated and delete attempt for them would result in graph error `General exception while processing` list details response for list `Corso_Restore_23-Dec-2023_14-54-05_Sharing Links` of 'hidden' type ``` { "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#sites('4892edf5-2ebf-46be-a6e5-a40b2cbf1c1a')/lists/$entity", "@odata.etag": "\"35697c04-415d-44ad-b328-527e32a20126,1\"", "createdDateTime": "2023-12-23T14:54:36Z", "description": "Use this list to track documents which have internal or anonymous sharing links in the site.", "eTag": "\"35697c04-415d-44ad-b328-527e32a20126,1\"", "id": "35697c04-415d-44ad-b328-527e32a20126", "lastModifiedDateTime": "2023-12-23T14:55:07Z", "name": "Corso_Restore_23Dec2023_145405_Sharing Links", "webUrl": "https://10rqc2.sharepoint.com/sites/CorsoCI/Corso_Restore_23Dec2023_145405_Sharing%20Links", "displayName": "Corso_Restore_23-Dec-2023_14-54-05_Sharing Links", "createdBy": { "user": { "displayName": "SharePoint App" } }, "parentReference": { "siteId": "10rqc2.sharepoint.com,4892edf5-2ebf-46be-a6e5-a40b2cbf1c1a,38ab6d06-fc82-4417-af93-22d8733c22be" }, "list": { "contentTypesEnabled": false, "hidden": true, "template": "sharingLinks" } } ``` #### Does this PR need a docs update or release note? - [x] :no_entry: No #### Type of change - [x] :computer: CI/Deployment #### Issue(s) https://github.com/alcionai/corso/actions/runs/7312141926/job/19922423733 #### Test Plan - [x] :green_heart: E2E --- src/cmd/purge/scripts/onedrivePurge.ps1 | 8 ++++++++ 1 file changed, 8 insertions(+) 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 ] {