/config/sharepoint-online/orphanedpersonalsitesretentionperiod
OneDrive retention for deleted users: Set-SPOTenant -OrphanedPersonalSitesRetentionPeriod
- tool
- SharePoint Online PowerShell
- file
- SharePoint Online tenant settings (Set-SPOTenant)
- key
- OrphanedPersonalSitesRetentionPeriod
- type
- Int32 (days, 30-3650)
- default
- 30
OrphanedPersonalSitesRetentionPeriod is the number of days a OneDrive is kept after its owner's account is deleted from Microsoft Entra ID. The default is 30 days; valid values are 30 to 3650. Set it after Connect-SPOService -Url https://contoso-admin.sharepoint.com:
Set-SPOTenant -OrphanedPersonalSitesRetentionPeriod 365
Get-SPOTenant | Select-Object OrphanedPersonalSitesRetentionPeriodThe same value can be changed in the SharePoint admin center (OneDrive retention setting).
The parameter is an Int32 in module 16.0.27709.12000 (checked offline; the range is enforced by the service, not by a PowerShell validation attribute):
Import-Module Microsoft.Online.SharePoint.PowerShell -DisableNameChecking
$par = (Get-Command Set-SPOTenant).Parameters['OrphanedPersonalSitesRetentionPeriod']
$t = $par.ParameterType
if ($t.IsGenericType) { $t = $t.GetGenericArguments()[0] }
'Type: ' + $t.Name
'Validation attributes: ' + @($par.Attributes | Where-Object { $_ -is [System.Management.Automation.ValidateArgumentsAttribute] }).CountOutput
Type: Int32 Validation attributes: 0
What happens when a user is deleted
- The user is deleted in the Microsoft 365 admin center or removed by directory synchronization. Blocking sign-in or removing the license does not start this process.
- The OneDrive is marked for deletion. If the user has a manager in Entra ID, the manager gets access and an email; otherwise the secondary owner set in the SharePoint admin center does (when access delegation is enabled).
- Seven days before the period ends, a reminder email is sent.
- At the end of the period the OneDrive goes to the site collection recycle bin for 93 days, where it can be restored only with PowerShell.
Retention policies win
Microsoft Purview retention policies and labels that cover OneDrive take precedence: content can be kept longer than this period, or deleted earlier. A OneDrive on eDiscovery hold is not deleted until the hold is removed. Use a retention policy with -OneDriveLocation when content must be kept for a fixed time.