How to Restore OneDrive For Business Site from Recycle Bin?

Requirement: Restore a Deleted OneDrive Site

How to Restore a OneDrive for Business Site using PowerShell?
When you remove a user from Office 365, his OneDrive is retained for 30 days and then its deleted. When a OneDrive site for an Office 365 user is deleted, it is moved to the tenant recycle bin first, and then it is permanently deleted after the retention period of 93 days typically.

PowerShell to Restore a Deleted OneDrive Site
Recovering a OneDrive for Business site is quite easy. Here is the PowerShell to restore the deleted OneDrive site.

Step 1: Connect to SharePoint Online from SharePoint Online Management Shell
Set the config parameter as per your tenant.
#Config Parameters

#Get Credentials to connect
$Cred = Get-Credential

#Connect to SharePoint Online Tenant Admin
Connect-SPOService -URL $AdminSiteURL -Credential $Cred
restore deleted onedrive site powershell

Step 2: Get All Deleted OneDrive Sites
Let's check if the OneDrive site is in the recycle bin. To get all deleted OneDrive for Business site collections, use:  
#Get All Deleted OneDrive Sites
Get-SPODeletedSite -IncludeOnlyPersonalSite -Limit All | Where { $_.URL -like "**"} 
This retrieves a list of OneDrive sites deleted and available for restore.

Step 3: Restore the OneDrive Site from Recycle bin
Once you find the OneDrive site from the above cmdlet, You can restore the OneDrive site using:
#Set OneDrive Site to Restore
$OneDriveSiteURL = ""

#Restore deleted onedrive site powershell
Restore-SPODeletedSite -Identity $OneDriveSiteURL
That's it. Your site should be back! We've restored OneDrive for Business site using PowerShell. If you want to permanently delete a Onedrive site, you have to delete it from the recycle bin as in SharePoint Online: Delete Site Collection from Recycle bin using PowerShell

No comments:

Please Login and comment to get your questions answered!

Powered by Blogger.