This sample script deletes specified SharePoint Online sites that have a retention policy applied by excluding them from the retention policy, deleting the site and then cleaning up the retention policy exclusions.
Users must modify the sample with the urls of the sites to exclude. Running the script without any change will not delete any site by accident.
Excluding the sites from the retention policy takes some time, from seconds to minutes, which is mentioned in the comments of the script. Ideally one would run the section to exclude the sites, wait, then run the section to delete the sites.
I didn't update preview.png or template.sample.json .
This sample script deletes specified SharePoint Online sites that have a retention policy applied by excluding them from the retention policy, deleting the site and then cleaning up the retention policy exclusions.
It uses PnP PowerShell to delete the sites and https://learn.microsoft.com/en-us/powershell/exchange/exchange-online-powershell-v2 to exclude them from the policy.
Users must modify the sample with the urls of the sites to exclude. Running the script without any change will not delete any site by accident.
Excluding the sites from the retention policy takes some time, from seconds to minutes, which is mentioned in the comments of the script. Ideally one would run the section to exclude the sites, wait, then run the section to delete the sites.
I didn't update preview.png or template.sample.json .