Requirement: Increase Onedrive for Business Retention Period
How to Configure OneDrive for Business Deleted User Retention?
Users with SharePoint Online license gets an 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 an OneDrive for the Business site collection is scheduled for deletion, the ownership of the site is transferred to the manager of the user. 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 that are marked for deletion is 30 days, and 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 an OneDrive site after a user account is marked for deletion, follow these steps:
- Login to OneDrive Admin center https://admin.onedrive.com/
- Click on the “Storage” link under the OneDrive admin center.
- In the storage page, we have the number of days to retain files in OneDrive after a user account is marked for deletion.
- 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 stays there for 93 days and then it is permanently deleted (If its not restored by the admin!). Microsoft documentation: https://docs.microsoft.com/en-us/onedrive/set-retention