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 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. More information is here: How to set OneDrive Retention Period?

Sometimes users may accidentally delete their OneDrive for Business sites, resulting in the loss of important files and data. In this tutorial, we will show you how to restore OneDrive for Business sites from the recycle bin, allowing you to recover your lost data.

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
$AdminSiteURL="https://crescent-admin.sharepoint.com"

#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 "*-my.sharepoint.com/personal*"} 

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 the following:

#Set OneDrive Site to Restore
$OneDriveSiteURL = "https://crescent-my.sharepoint.com/personal/salaudeen_crescent_com"

#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

Summary

In conclusion, restoring a OneDrive for Business site from the recycle bin is a simple process that can be done by following the steps outlined in this tutorial. Following these steps, users can recover their lost files and data, and regain access to their OneDrive for Business site. It’s important to remember that the site will only be available in the recycle bin for 93 days after deletion, after that, it’s not recoverable.

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!

2 thoughts on “How to Restore OneDrive For Business Site from Recycle Bin?

  • Can you please check the below command if correct for restore data from recycle bin of a user

    $SharePointSiteURL = “https://duffandphelpsind-my.sharepoint.com/personal/satyanarayana_murthyvinnakota_duffandphelps_com”

    # User who deleted files
    $UserEmailWhoDeletedFiles = “Satyanarayana.MurthyVinnakota@mydomain.com”

    # My Crds
    $SPOCreds = Get-Credential -UserName “Admin-Ranu.Sakpal@mydomain.com” -Message “Password”

    # Connect
    Connect-PnPOnline -Credentials $SPOCreds -Url $SharePointSiteURL

    # Check Item Count
    $Items = Get-PnPRecycleBinItem | ? -Property DeletedByEmail -EQ $UserEmailWhoDeletedFiles
    $Items.Count

    #Restore All Items
    $Items = Get-PnPRecycleBinItem | ? -Property DeletedByEmail -EQ $UserEmailWhoDeletedFiles

    ForEach ($item in $items) {
    Restore-PnpRecycleBinItem -Identity $item -Force
    }

    Reply

Leave a Reply

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