SharePoint Online: How to Restore a Deleted Site Collection using PowerShell?

Requirement: Restore a Deleted Site Collection in SharePoint Online.

How to Restore a Deleted Site Collection in SharePoint Online?

If you are a SharePoint Online administrator or a Microsoft 365 global Admin, you may know that site deletions can happen accidentally, and you may need to restore them as quickly as possible. How do I restore a SharePoint site from the recycle bin? Well, this blog post will teach you how to restore a deleted SharePoint Online site, and we will also share how to restore the deleted site using PowerShell. Let’s get started!

SharePoint recycle bin provides the ability to recover even when an entire site collection is deleted. To restore a deleted site collection in SharePoint Online, follow these steps:

  1. Login to the Microsoft 365 admin Center >> Click on the “SharePoint Admin Center” with an account with admin permissions for your organization at >> Expand Sites >> “Deleted Sites” in the new SharePoint admin center.
  2. On the Recycle bin page, you should see a list of all the site collections deleted within your organization.
  3. Pick the one you want to restore and click on the “Restore” button from the command bar. (Make sure you have a site selected, otherwise, you won’t see the restore button!)
  4. You’ll get a message “Site Restored” once the restore operation completes. restore sharepoint online site using powershell

The site collection will be restored and available immediately and moved from “Deleted sites” to “Active sites”. Any type of site, such as a Team site or communication site, can be restored with the above instructions. Note that this process will only work if the site collection was deleted within the last 93 days. If it has been longer than that, you will need to contact Microsoft Support for assistance to restore it from the backup.

Restore a deleted site in SharePoint Online from the classic admin center:

Similarly, to restore a SharePoint Online site in the classic SharePoint Online admin center:

  1. Click on the “Site Collection” link in the left navigation.
  2. On the ribbon, click on the “Recycle Bin” button. You’ll see the list of all Site Collections, along with when they were deleted and how many days are remaining before they disappear from the recycle bin.
  3. To restore deleted site collection, select the site collection you want to restore on the Recycle Bin page, and click on the “Restore Deleted Items” button in the Ribbon.
    sharepoint online restore deleted site collection
  4. Click on the “Restore” button in the Popup window to restore the selected site collection.
The default retention period for deleted items in SharePoint Online is 93 days! However, this applies to classic SharePoint sites only! You have up to 93 days to restore. For modern group connected site collections, the retention period is limited to maximum 30 days, as enforced by Azure AD recycle bin settings.

SharePoint Online: PowerShell to Restore a Deleted Site Collection

When a SharePoint Online site collection is deleted, it is placed in the recycle bin and permanently deleted after the retention period. Recovering a SharePoint Online site is relatively easy, and here is the PowerShell to restore the deleted site collection.

Step 1: Connect to SharePoint Online from SharePoint Online Management Shell

Open the SharePoint Online Management Shell and Connect to your SharePoint Online tenant using the following script:

#Config Parameters

#Get Credentials to connect
$Cred = Get-Credential

#Connect to SharePoint Online Tenant Admin
Connect-SPOService -URL $AdminSiteURL -Credential $Cred

Step 2: Get a List of All Deleted Site Collections

To check if the site collection is available to restore or not, run the following command:

#Get All Deleted Sites

This gives you a list of all deleted SharePoint sites.

Step 3: Restore the Site collection from Recycle bin

Finally, run this PowerShell command to restore the site:

#sharepoint online restore deleted site powershell
Restore-SPODeletedSite -Identity ""
sharepoint online powershell restore site collection

That’s it. Your site should be back! We’ve restored the SharePoint Online site collection using PowerShell.

Restore Deleted SharePoint Online Site using PnP PowerShell

If you accidentally delete a site collection in SharePoint Online, you can restore it from the Recycle Bin using the PnP PowerShell cmdlet Restore-PnPTenantRecycleBinItem.

#Config Variables
$TenantURL = ""
$DeletedSiteURL =""

#Connect to PnP Online
Connect-PnPOnline -Url $TenantURL -Credentials (Get-Credential)
#Get Deleted Site from Recycle Bin
$DeletedSite = Get-PnPTenantRecycleBinItem | Where {$_.URL -eq $DeletedSiteURL}

    #restore site collection sharepoint online powershell
    Restore-PnPTenantRecycleBinItem -Url $DeletedSiteURL -Force -ErrorAction Stop
    Write-Host -f Green "Site Collection '$DeletedSiteURL' Restored Successfully!"
    Write-host -f Yellow "Could not Find Deleted site:"$DeletedSiteURL

This PowerShell restores the deleted site to its original location in SharePoint Online!

If you want to delete a site collection permanently, you have to delete it from the recycle bin as in SharePoint Online: Delete Site Collection from Recycle bin using PowerShell

How to recover deleted files from SharePoint Online?

To restore deleted items from the recycle bin: Login to your SharePoint Online site >> Click on Settings gear >> Site Contents >> Click on the “Recycle bin” link from the top-right area of the page. On the Recycle bin page, Select the document(s) you would like to restore and then click “Restore Selection”.
More info: Restore files in SharePoint Online

How do I restore a deleted subsite in SharePoint Online?

To restore a subsite, Login to SharePoint Online Site collection as a site collection administrator. Navigate to Site Settings >> Click on “Recycle bin” under site collection administration to open the site collection recycle bin, Click on the “Second-stage recycle bin” link and select the subsite to restore, and click on the “Restore” button in the ribbon.
More info: Restore deleted subsite in SharePoint Online

How do I restore the previous version in SharePoint Online?

To restore a previous version of a document: Browse to the document library >> Right-click on the document and choose “Version History” from the menu. On the version history page, hover your mouse over the version you want to restore and click on “Restore” from the context menu.
More info: Restore the previous version in SharePoint Online

How to restore a OneDrive for Business site?

To restore a deleted OneDrive for Business site, use PowerShell cmdlet: Restore-SPODeletedSite -Identity “OneDriveSiteURL”
More info: Restore OneDrive for Business Deleted site

How to Restore a Permanently deleted site?

If you have permanently deleted a site through admin center or PowerShell command Remove-SPODeletedSite, You have to raise a Microsoft support case to restore it! o to, Click on “Help and Support”, Enter your query and create a new Microsoft Service Request.

Salaudeen Rajack

Salaudeen Rajack - Information Technology Expert with Two-decades of hands-on experience, specializing in SharePoint, PowerShell, Microsoft 365, and related products. He has held various positions including SharePoint Architect, Administrator, Developer and consultant, has helped many organizations to implement and optimize SharePoint solutions. Known for his deep technical expertise, He's passionate about sharing the knowledge and insights to help others, through the real-world articles!

Leave a Reply

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