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 contents in Office 365. When a user leaves the company, the user account is deleted from the Active Directory, and it gets synchronized to 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 “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:
- Login to SharePoint Admin center at https://YourDomain-Admin.SharePoint.com
- Click on the “Settings” link under the left navigation
- In the settings page, click on “Retention” next to “OneDrive” App. The retention settings have the number of days to retain the OneDrive after a user account is deleted.
- Enter the number of days you want to retain 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 for 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 beings 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.
#Parameters $TenantAdminURL = "https://crescent-admin.sharepoint.com" #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 it’s not restored by the admin!). Microsoft documentation: https://docs.microsoft.com/en-us/onedrive/set-retention