Restore a deleted OneDrive
When you delete a user in the Microsoft 365 admin center (or when a user is removed through Active Directory synchronization), the user's OneDrive will be retained for the number of days you specify in the OneDrive admin center. (For info, see Set the default file retention for deleted OneDrive users.) The default is 30 days. During this time, shared content can still be accessed by other users. At the end of the time, the OneDrive will be in a deleted state for 93 days and can only be restored by a global or SharePoint admin.
Restore a deleted OneDrive when the deleted user no longer appears in the Microsoft 365 admin center
If the user was deleted within 30 days, you can restore the user and all their data from the Microsoft 365 admin center. To learn how, see Restore a user in Office 365. If you deleted the user more than 30 days ago, the user will no longer appear in the Microsoft 365 admin center, and you'll need to use PowerShell to restore the OneDrive.
Connect to SharePoint Online as a global admin or SharePoint admin in Office 365. To learn how, see Getting started with SharePoint Online Management Shell.
Determine if the OneDrive is available for restore
- If you know the URL of the OneDrive, run the following command:
Get-SPODeletedSite -Identity <URL>
- If you don't know the URL of the deleted OneDrive, run the following command:
Get-SPODeletedSite -IncludeOnlyPersonalSite | FT url
- If the OneDrive appears in the results, it can be restored.
- Restore the OneDrive to an active state:
Restore-SPODeletedSite -Identity <URL>
- Assign a site collection administrator to the OneDrive to access the needed data:
Set-SPOUser -Site <URL> -LoginName <UPNofDesiredAdmin> -IsSiteCollectionAdmin $True
Permanently delete a OneDrive
After you recover the data you need from the OneDrive, we recommend that you permanently delete the OneDrive by running the following command:
Remove-SPOSite -Identity <URL>
When you permanently delete a OneDrive, you will not be able to restore it.