Restoring deleted user's onedrive

Scenario: You have a staff who left your firm 6 months (180 Days) ago and you just realized there used to be a folder that contains vital files you forgot to collect from him before he left and these files are currently needed for a multi-billion dollar project.

AT first, knowing that your files on OneDrive for business stay for 30 days after which its inaccessible from the users end after the account has been marked for deletion gives you reasons to worry. The natural thing to think and do is that the files are totally gone. But your instinct still tells you that there should still be something to be done to save the day.

Look no further as I have compiled an easy but professional way an administrator can achieve this without losing sleep and sweat. PowerShell cmdlets – yes, you heard me right. Some actions that are smartly hidden in the GUI of office 365 can be implemented and utilized using PowerShell script which queries the kernel of your office 365 installation to perform admin functions which in most cases are irreversible.

Kindly be informed that there is a recommended way of delegating deleted user’s OneDrive files to be accessible by designated personnel (Secondary Admins) which will reduce the overhead time spent in using the restore method I am proposing. Use this link for OneDrive Retention and Deletion.

The method I am proposing is as below from a Microsoft Documentation;

  1. Download the latest SharePoint Online Management Shell.
  2.  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.”
  3.  On the Download Center page, select your language and then click the Download button. You’ll be asked to choose between downloading a x64 and x86 .msi file. Download the x64 file if you’re running the 64-bit version of Windows or the x86 file if you’re running the 32-bit version. If you don’t know, see https://support.microsoft.com/help/13443/windows-which-operating-system. After the file downloads, run it and follow the steps in the Setup Wizard.
  4. Connect to SharePoint Online as a global admin or SharePoint admin in Office 365. To learn how to see Getting started with SharePoint Online Management Shell.
  5. Determine if the OneDrive is available for restore
  • If you know the URL of the OneDrive, run the following command:

PowerShellCopy Get-SPODeletedSite -Identity <URL>

A user’s OneDrive URL is based on their username. For example, https://microsoft-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:

PowerShellCopy Get-SPODeletedSite -IncludeOnlyPersonalSite | FT URL

  • If the OneDrive appears in the results, it can be restored.

Restore the OneDrive to an active state:

PowerShellCopy Restore-SPODeletedSite -Identity <URL>

Assign a Secondary administrator to the OneDrive to access the needed data:

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

Going through these steps will ensure you as an Admin can have access to the deleted user’s files, sync and edit as best as you want. Remember that deleting the User’s OneDrive link permanently using Powershell can be reversed.

Feel free to get in touch with me!

Leave a Reply

Your email address will not be published. Required fields are marked *

You may also like