How to Restore OneDrive For Business Site from Recycle Bin?

Requirement: Restore a Deleted OneDrive Site

How to restore an OneDrive for Business Site using PowerShell?

When you remove a user from Office 365, his OneDrive is retained for 30 days, and then it’s deleted. When a OneDrive site for an Office 365 user is deleted, it is moved to the tenant recycle bin first. 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 relatively 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 restoration.

Step 3: Restore the OneDrive Site from the 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 delete a OneDrive site permanently, you have to delete it from the recycle bin as in SharePoint Online: Delete Site Collection from Recycle bin using PowerShell

Salaudeen Rajack

Salaudeen Rajack - SharePoint Expert with Two decades of SharePoint Experience. Love to Share my knowledge and experience with the SharePoint community, through real-time articles!

Leave a Reply

Your email address will not be published.