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.
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.
- Sign in to the Microsoft 365 admin center.
- Navigate to Users –> Deleted users.
- Now, select the user who you want to restore.
- Then, choose Restore user.
- Follow the prompts to set their password, and then select Restore.
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>
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,
- Sign in to the SharePoint admin center.
- Navigate to Settings –> OneDrive Retention.
- You can enter a value between 30 and 3650 in the Days to retain files of a deleted user’s OneDrive box.
- 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. if you’re interested in learning more about OneDrive storage or deleted SharePoint sites, you can refer to the blogs on change OneDrive storage for users and 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.