How to Restore a Deleted OneDrive?

How to Restore a Deleted OneDrive?

Do you know what happens to a user’s OneDrive account when they leave the organization? Let me break it down for you. When a user’s account is deleted from Microsoft Entra, their OneDrive files are not immediately deleted. Instead, they are retained for 30 days by default. Throughout this period, shared content remains accessible to others. After the initial 30 days, the OneDrive account enters a site collection recycle bin, where it remains for the next 93 days. Only Global or SharePoint admins can restore it during this time. Curious to learn more? Let’s delve into how admins can restore a deleted OneDrive in the Microsoft 365 environment.

There are two scenarios to consider when restoring a user’s OneDrive.

Restore a Deleted OneDrive in Microsoft 365 Admin Center

If a user’s account is recently deleted (within the past 30 days), admins can restore the entire user account, including their OneDrive, through the Microsoft 365 admin center. This simplifies the process and allows admins to quickly recover a user’s data without needing to use PowerShell.

To restore a user deleted within 30 days, follow the below-mentioned steps.

  1. Sign in to the Microsoft 365 admin center.
  2. Navigate to Users –> Deleted users.
  3. Now, select the user who you want to restore.
  4. Then, choose Restore user.
  5. Follow the prompts to set their password, and then select Restore.

Restore a Deleted OneDrive Using PowerShell

If it’s been more than 30 days since the user and their OneDrive were deleted, the standard recovery methods won’t work. In this case, restoring the deleted OneDrive sites requires using PowerShell with global admin or SharePoint admin permissions.

Firstly, connect to SharePoint Online PowerShell as the user’s OneDrive account deletion is synchronized to SharePoint.

Before initiating the restoration process, it’s essential to confirm if the OneDrive is available for recovery. Depending on whether you have the URL of the OneDrive or not, follow the corresponding steps.

If you know the URL, run the following cmdlet.

Get-SPODeletedSite -Identity <URL>

Replace the ‘URL’ with the deleted user’s OneDrive link. The URL typically follows the format: ‘https://tenant-my.sharepoint.com/personal/username_tenant_com’.

If the URL is unknown, execute the below cmdlet. Only the listed OneDrive accounts can be restored.

Get-SPODeletedSite -IncludeOnlyPersonalSite | FT url

After the OneDrive is confirmed for restoration, proceed with the following steps.

Restore-SPODeletedSite -Identity <URL>

The cmdlet ‘Restore-SPODeletedSite’ initiates the restoration process, bringing the OneDrive back to an active state.

When you recover a deleted OneDrive, you need to grant OneDrive access to another user with administrative rights to manage it. To assign an admin to the OneDrive, run the following cmdlet.

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

Once you recover all the necessary data, it’s advisable to initiate permanent deletion using the following PowerShell commands.

Remove-SPOSite -Identity <URL>
Remove-SPODeletedSite -Identity <URL>

NoteIt’s crucial to keep in mind that once you permanently delete a OneDrive, it cannot be restored.

How to Set the OneDrive Retention for Deleted Users?

As we have seen earlier, the default retention period is 30 days. However, SharePoint admins have the flexibility to modify the default retention for deleted OneDrive users.

To change the retention time for OneDrive user accounts,

  1. Sign in to the SharePoint admin center.
  2. Navigate to Settings –> OneDrive Retention.
  3. You can enter a value between 30 and 3650 in the Days to retain files of a deleted user’s OneDrive box.
  4. Click Save.

The setting applies to both the next user to be deleted and any users currently in the deletion process. The retention date countdown begins as soon as the user account is deleted in the Microsoft 365 admin center.

By following these procedures, administrators can efficiently restore deleted OneDrive accounts, ensuring the preservation and accessibility of valuable user data within Microsoft 365. Likewise, if you are interested in knowing more about deleted SharePoint sites, you can refer to the blog on managing deleted SharePoint sites.

I hope this blog covers all the ways to restore a deleted OneDrive in Microsoft 365 environment. Feel free to reach us in the comment section for any queries.

How to Restore a Deleted OneDrive?

by Praba time to read: 3 min
0