pnp / script-samples

A sample gallery of scripts to manage all things Microsoft 365.
https://pnp.github.io/script-samples/
MIT License
220 stars 136 forks source link

Add "Delete SharePoint Online sites that have retention policies" sample #696

Closed jackpoz closed 5 months ago

jackpoz commented 6 months ago

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 .

pkbullock commented 5 months ago

Thank you @jackpoz for this awesome sample, sorry for the delay in processing but this will be live shortly 🎉

jackpoz commented 5 months ago

Thanks for accepting it 🚀