How to Exclude a SharePoint Online Site from Retention Policy?
Requirement: Remove retention policy from SharePoint Online site.
Exclude a SharePoint Online site from the Retention Policy
When you create a retention policy in Microsoft 365 – SharePoint Online, it’s automatically applied to all sites within your organization. You can remove the policy if you don’t want the policy to apply to a specific site. In this article, we’ll show you how to remove a retention policy from a SharePoint Online site.
Follow these steps to exclude a site collection from the retention policy in SharePoint Online:
- Login to Microsoft 365 admin center >> Open the Compliance Admin Center (If you don’t find it, click on “All Admin Centers” on the left side menu and open the “Compliance” link)
- In Compliance Admin Center, click on “Policies” from the left-hand navigation menu bar >> Open the “Retention” link.
- Find the Retention policy which is protecting SharePoint, or there may be a rule protecting everything in Microsoft 365, depending on your settings. In my case, it’s named “Retention Policy”.
- Click on the “Edit” button from the context menu of the policy
- Click on the Next buttons to navigate to the “Locations” tab, Click on “Edit” button under “Excluded” column.
- Add the site URL in exclude list, to remove the site from the retention policy.
- Select the Sites you wish to exclude from the retention list, and click on “Done”.
- Click on Next >> Next >> and “Submit” the changes.
Wait for some time (10 to 60 min) for the policy status to turn “On – Success”. Now, try to delete any objects or even the site! This time it should proceed without any errors.
Exclude SharePoint site Collection from retention policy using PowerShell
Let’s take a look at how to exclude a particular SharePoint Online site from your retention policy using PowerShell.
#Parameter
$SiteURL = "https://crescent.sharepoint.com/sites/Marketing"
$PolicyName = "Retention Policy"
Try {
#Connect to Compliance Center through Exchange Online Module
Connect-IPPSSession
#Get the Policy
$Policy = Get-RetentionCompliancePolicy -Identity $PolicyName
If($Policy)
{
#Exclude site from Retention Policy
Set-RetentionCompliancePolicy -AddSharePointLocationException $SiteURL -Identity $Policy.Name
}
}
Catch {
write-host "Error: $($_.Exception.Message)" -foregroundcolor Red
}
Can you post the script to add multiple groups imported from a csv file to the retention exception? When I use import from csv and use foreach-object (-addmorderngrouplocationexception), only the first group from the csv file is added to the policy and the script terminated with an error (error: previous changes to the policy are being deployed).
Is it possible to exclude a folder with in a library ?
No, The exclusion applies at the site level.
what is the limit to exclude
Is there a way to get the list of excluded sites on PowerShell? I can’t see anything with Get-RetentionCompliancePolicy
Many thanks for posting the PS code to do this!
The interface method is horrendous and so unintuitive, even by Microsoft standards. It’s also another fine example of MS not bothering to design to enterprise scale – the panel only load 100 SharePoint sites/M365 Groups (total!!) and the search only uses the displayed list. Seriously poor.