How to Set Retention Period in OneDrive for Business?

Requirement: Increase OneDrive for Business Retention Period.

How to Configure OneDrive for Business Deleted User Retention?

Users with a SharePoint Online license get a OneDrive for Business site to store their content in Office 365. When a user leaves the company, the user account is deleted from the Active Directory, and it gets synchronized to the Microsoft 365 environment. Then the OneDrive cleanup job runs, and the OneDrive site is marked for deletion. When a OneDrive for the Business site collection is scheduled for deletion, the site’s ownership is transferred to the user’s manager. In case, the Manager Property is missing for the user account profile that is being deleted, then the OneDrive cleanup job tries to send an Email notification to the “Secondary Owner” if it is populated.

The manager or the secondary owner will receive an email notification about the OneDrive site and that the OneDrive will be deleted at the end of the retention period. They’ll get a second email notification Seven days before the retention period expires. After 7 days, the OneDrive for the deleted user is moved to the site collection recycle bin and kept for an additional 93 days. The default retention period for OneDrive sites marked for deletion is 30 days. You can extend the retention period either in the OneDrive admin center or by using PowerShell.

Set Retention Period in OneDrive for Business

To set the number of days to retain a OneDrive site after a user account is marked for deletion, follow these steps:

  1. Login to the SharePoint Admin center at
  2. Click on the “Settings” link under the left navigation
  3. On the settings page, click on “Retention” next to the “OneDrive” App. The retention settings have the number of days to retain the OneDrive after a user account is 365 onedrive for business retention
  4. Enter the number of days you want to retain the OneDrive site after a user account is marked for deletion in “Days to retain files in OneDrive after a user account is marked for deletion”. The minimum value for this setting is 30 days, and the maximum value is 3650 days (10 years).

PowerShell to Set OneDrive for Business Retention Period

You can configure how long to retain the files after a user is marked for deletion using the Set-SPOTenant PowerShell cmdlet. The setting will really take effect for the next user that is deleted, and the count begins as soon as the user account is deleted in the Microsoft 365 admin center. Let’s configure a retention policy for OneDrive for Business for the deleted users to 90 days.

$TenantAdminURL = ""

#Connect to Admin Center
Connect-SPOService -Url $TenantAdminURL -Credential (Get-Credential)

#Set onedrive for business retention period
Set-SPOTenant -OrphanedPersonalSitesRetentionPeriod 90

Once the retention period is reached, The OneDrive site will be moved to the Recycle bin and stay there for 93 days, and then it is permanently deleted (If the admin does not restore it!). Microsoft documentation:

In conclusion, setting a retention period in OneDrive for Business can help to keep your data organized and secure. The process of setting retention periods in OneDrive for Business is relatively simple and can be done through the Microsoft 365 admin center or PowerShell as explained above.

If you are looking for a OneDrive retention policy for deleted files, refer to: How to Create a Retention Policy for OneDrive?

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!

Leave a Reply

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