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 is retained for the number of days you specify in the SharePoint admin center. (For info, see Set the default file retention for deleted OneDrive users.) The default is 30 days. During this time, other users can still access shared content. At the end of the time period, the OneDrive remains in a deleted state for 93 days and can only be restored by a SharePoint Administrator.

For info about using Files Restore to restore a OneDrive to a previous point in time, see Restore your OneDrive.

For info about restoring items from the recycle bin in OneDrive, see Restore deleted files or folders.

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 Microsoft 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 need to use PowerShell to restore the OneDrive.

  1. Download the latest SharePoint Online Management Shell.

    Note

    If you installed a previous version of the SharePoint Online Management Shell, go to Add or remove programs and uninstall "SharePoint Online Management Shell."

  2. Connect to SharePoint as a SharePoint Administrator in Microsoft 365. To learn how, see Getting started with SharePoint Online Management Shell.

  3. Determine if the OneDrive is available for restore.

    • If you know the URL of the OneDrive, run the following command:

      Get-SPODeletedSite -Identity <URL>
      

      A user's OneDrive URL is based on their username. For example, https://contoso-my.sharepoint.com/personal/user1_contoso_com. You can find their username on the Active users (or Deleted users) page in the Microsoft 365 admin center.

    • 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.

  4. Restore the OneDrive to an active state:

    Restore-SPODeletedSite -Identity <URL>
    
  5. Assign an administrator to the OneDrive to access the needed data:

    Set-SPOUser -Site <URL> -LoginName <UPNofDesiredAdmin> -IsSiteCollectionAdmin $True
    

For more info about these cmdlets, see Get-SPODeletedSite and Restore-SPODeletedSite.

Note

When a OneDrive is restored, it will continue to remain available until it's explicitly deleted.

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>
Remove-SPODeletedSite -Identity <URL>

Caution

When you permanently delete a OneDrive, you will not be able to restore it.

See also

OneDrive retention and deletion
Manage site redirects