How to restore deleted OneDrive site from the bin in Office365

A customer has requested whether it was possible to restore a OneDrive site that had been deleted when the user’s account was marked for deletion in AD. After a bit of research, I was able to restore the site back and retrieved the files (luckily it was deleted less than 30 days ago).

First, there is a setting in OneDrive admin centre (https://admin.onedrive.com) -> Storage tab, where you could specify the retention period of a OneDrive site, once its associated user account is deleted. The default is set to 30 days but this can be changed to 3,650 days (10 years).

See: https://support.office.com/en-us/article/Preserve-OneDrive-files-after-users-leave-the-organization-fa1641ea-9f03-4f34-a826-dbd8697e76fe

Now, to retrieve the deleted site from the bin, follow the following steps:

Connect-SPOService -Url <https://yourdomain-admin.sharepoint.com>

Make sure you use the admin credential.

  • To determine whether the site is available, we run the Get-SPODeletedSite command to check:

          Get-SPODeletedSite -IncludeOnlyPersonalSite | FT url

This will retrieve all the deleted OneDrive sites in the bin (if they haven’t been removed in the cloud).

  • Once you have identified the site, run the Restore-SPODeletedSite command to get the site back:

         Restore-SPODeletedSite -Identiy <https://yourdomain-my.sharepoint.com/personal/username>

  • Now, we also need to set the owner of the site to yourself so you could see the files:

         Set-SPOUser -Site <https://yourdomain-my.sharepoint.com/personal/username> -LoginName <your username> -IsSiteCollectionAdmin $true

Categories: O365, Sharepoint Online
Tags: