Master How to Set Retention Policy in SharePoint Online [Updated]

Mack John ~ Published: September 25th, 2024 ~ SharePoint ~ 6 Minutes Reading

One of the most common questions by IT admins and technical support trainees is “How to set a Retention Policy in SharePoint Online?”. If you are also eager to understand the answer to this question. Don’t worry!, in this step-by-step guide, we will walk you through the process of applying Retention policies.

Retention policies in SharePoint Online help to manage your organization’s data by ensuring compliance, reducing storage costs, and preventing data loss. If you are unaware of detailed concepts of Sharepoint you can read “What is SharePoint?

In this guide, we will explore the importance of retention policies and their impact. However, retention policies can be configured through the “Admin Center” but PowerShell scripts help to automate the process. Additionally, we will discuss how to effectively set them using both the Admin Center and PowerShell.

What Are Retention Policies in SharePoint Online?

Retention policies are a set of rules based on organizational or legal requirements that are applied to determine how long data is kept in Sharepoint after a specific period. Importantly, it also decides how data is managed once the retention period ends. Additionally, these policies ensure that unused documents are either deleted or archived when no longer needed. To understand how to set Retention policies in SharePoint Online, we have to get an idea about the types of retention policies.

There are two primary types of retention policies:

  • Static Retention Policies – These policies help to apply a set retention period for all data.
  • Adaptive Retention Policies – These policies help to automatically change the retention period depending on different conditions.

Why Retention Policies Are Crucial for SharePoint Management

The need for retention policies cannot be overdrawn or overstretched. Here are the key reasons for their importance:

  • Compliance with Legal Requirements – Policies regarding data retention are strict in multiple countries. Organizations may avoid penalties and legal problems by ensuring they follow these rules and set Retention policies in SharePoint online.
  • Improved Storage Management and Cost Efficiency – SharePoint Online offers a considerable amount of cloud storage, but it is not free. As your data grows, you may need to purchase additional storage. In this situation, retention policies can help to manage these costs by automatically deleting outdated information.
  • Clutter-Free Search – Outdated information can clutter search results which makes it harder to find what you need. Retention policies can enhance search performance and accuracy by automatically removing irrelevant content once it expires.

How to Set Retention Policy in SharePoint Online Using the Admin Center

Creating retention policies through the Admin Center is straightforward. Here’s a step-by-step guide:

Step 1.  Firstly, navigate to the Microsoft 365 App Launcher and select the Compliance option.

Step 2. Secondly, from the left-hand menu, go to Data Lifecycle Management and select Microsoft 365. Within this section, open the Retention Policies tab.

Step 3. Thirdly, click on New Retention Policy, assign a name and description to your policy, and proceed by clicking Next.

Step 4. If necessary, assign any specific administrative units or leave it blank if you want the policy to apply universally.

Step 5. Choose between a Static Retention Policy or an Adaptive Retention Policy, depending on your organizational needs.

Step 6. Specify where the policy should be applied. You can choose from SharePoint sites, OneDrive accounts, or entire groups.

Step 7. Set the retention duration. You can choose to retain items for a specific number of days, months, or years.

Step 8. Finally, after setting the policy’s conditions, review all details and click Submit.

Note – Be aware that this settings can take up to a week for policies to fully take effect across your SharePoint environment.

Setting Retention Policies via PowerShell

For those more comfortable with scripting, PowerShell provides a quicker way to create and manage retention policies in SharePoint Online. Below are steps for how to set up a retention policy in Sharepoint Online using PowerShell.

Try {
    Connect-IPPSSession
    $NewPolicy = New-RetentionCompliancePolicy `
    -Name "SharePoint Retention Policy" `
    -Comment "Policy for SharePoint Data Retention" `
    -SharePointLocation All `
    -OneDriveLocation All `
    -ModernGroupLocation All `
    -Enabled $True
    New-RetentionComplianceRule `
    -Name "Retention Policy Rule" `
    -Policy $NewPolicy.Id `
    -RetentionDuration 365 `
    -RetentionComplianceAction KeepAndDelete `
    -ExpirationDateOption ModificationAgeInDays
}
Catch {
    write-host "Error: $($_.Exception.Message)" -foregroundcolor Red
}

This script creates a policy that retains all data in SharePoint and OneDrive for 365 days and automatically deletes items after this period.

Impact of Retention Policies on SharePoint Sites

Now you have  learned how to set up a retention policy in Sharepoint Online but implementing a retention policy introduces several key effects that administrators should be aware of:

  • Inability to Delete Sites – A SharePoint site that has a retention policy applied to it cannot be erased unless the policy is changed or removed. An error message will appear if the site is attempted to be deleted.
  • Restrictions on Deleting Non-Empty Folders – Until the items inside a folder go beyond the retention policy timeframe, the folder cannot be removed.
  • Preservation Hold Library – To ensure that no data is permanently destroyed before its retention period is finished, deleted items are moved to a Preservation Hold Library and stored there until their retention period has expired.

How Retention Works Behind the Scenes

SharePoint Retention Policy deletes data or sites automatically after the retention period is over. Here is a simple way through which this procedure operates:

  • Deleted data appear in the Recycle Bin. The system account is shown in the “Deleted By” column which suggests that the deletion was done automatically.
  • Every 30 days, SharePoint examines data for expiration. It means the data is stored until the retention policy detects its expiration.

The Aftermath of Data Deletion in SharePoint

Once data is removed as per the retention policy, you cannot restore it. This is why many SharePoint administrators prefer to use vendor tools. One of the best tools of this kind is the SharePoint Migrator which helps to create copies of essential data into another tenant before deletion occurs. However, this procedure is also known as SharePoint tenant to tenant migration. You can simply download this tool from the below download button and start using this tool to avoid the data loss situation.

Final Thoughts

In SharePoint Online, retention policies are crucial for maintaining legal compliance, effectively managing storage, and avoiding data loss. However, it is crucial to review these retention policies regularly whether you manage them using PowerShell or the Admin Center. 

In this article, we have shown how to set a retention Policy in SharePoint Online. You can increase overall data management and security as well as optimize your organization’s data governance approach using this guide