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:

  1. 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)
  2. In Compliance Admin Center, click on “Policies” from the left-hand navigation menu bar >> Open the “Retention” link.remove retention policy from sharepoint online site
  3. 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”.
  4. Click on the “Edit” button from the context menu of the policyexclude sharepoint online site from retention policy
  5. Click on the Next buttons to navigate to the “Locations” tab, Click on “Edit” button under “Excluded” column.how to exclude a sharepoint online site from retention policy
  6. Add the site URL in exclude list, to remove the site from the retention policy. sharepoint online delete site with retention policy
  7. Select the Sites you wish to exclude from the retention list, and click on “Done”.sharepoint online site retention policy
  8. Click on Next >> Next >> and “Submit” the changes.sharepoint online delete site retention policy

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
}

Salaudeen Rajack

Salaudeen Rajack - Information Technology Expert with Two-decades of hands-on experience, specializing in SharePoint, PowerShell, Microsoft 365, and related products. He has held various positions including SharePoint Architect, Administrator, Developer and consultant, has helped many organizations to implement and optimize SharePoint solutions. Known for his deep technical expertise, He's passionate about sharing the knowledge and insights to help others, through the real-world articles!

7 thoughts on “How to Exclude a SharePoint Online Site from Retention Policy?

  • I would like to create a retention policy that will automatically delete files from preservation hold library after defined period (but keep those files in document library). Is it that possible? I find out that when i exclude sharepoint site from retention policy, almost all data are deleted from preservation hold library. Is it some feature or how is this happening? Thanks for answers.

    Reply
  • 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).

    Reply
  • Is it possible to exclude a folder with in a library ?

    Reply
  • what is the limit to exclude

    Reply
  • Is there a way to get the list of excluded sites on PowerShell? I can’t see anything with Get-RetentionCompliancePolicy

    Reply
  • 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.

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *