SharePoint Online: Delete Site Collection from Recycle Bin using PowerShell

Requirement: Delete Site Collection from the recycle bin in SharePoint Online.

How to Delete SharePoint Online Site from recycle bin?

In this article, we will show you how to delete a site collection from the recycle bin in SharePoint Online. Deleting a site collection from the recycle bin permanently deletes a site collection, and the site cannot be restored without the help of Microsoft support. So, Before deleting a site collection from the recycle bin, make sure that you are absolutely certain that you want to delete it.

When we delete a SharePoint Online site collection, it goes to the Recycle Bin and stays there for 93 days. However, at times we may want to completely delete the site from the recycle bin as well, for reasons such as:

  • We ran a shortage of storage quota and want to delete the site collection to obtain the space.
  • We need to create a new site collection with the same URL as the deleted site (Otherwise, It gives the error: New-SPOSite : A site already exists at URL https://yourtenant.sharepoint.com)

Permanently Delete Site Collection from the Recycle bin

My other article, How to Delete a SharePoint Site, explains the easier ways to delete modern sites/communication site/team site/classic sites in SharePoint. In short, if you are a site owner, you can delete any unnecessary SharePoint sites with these steps: Open the Modern SharePoint site >> Click on the site settings gear icon >> Choose Site Information >> Click on Delete Site >> Confirm the deletion by checking the box and clicking Delete. When you delete a site, it goes to the tenant recycle bin.

To delete a site permanently from the recycle bin in SharePoint Online, follow these steps:

  1. Login to Office 365 Admin >> “SharePoint Admin Center” as SharePoint Administrator.
  2. Click on the “Sites” >> “Deleted Sites” link from the left navigation to get a list of all deleted SharePoint sites.
  3. Select the site from the list by clicking the checkbox and clicking on the Permanently Delete button in the toolbar.
  4. Confirm the delete operation in the warning message prompt!
    sharepoint online delete site collection from recycle bin powershell

Remember, deleting a SharePoint site is a permanent action, so it’s essential to carefully consider the implications and have a proper backup strategy in place before proceeding with site deletions.

Let’s see the SharePoint Online PowerShell to delete site collection from the recycle bin.

SharePoint Online: Delete Site Collection from Recycle Bin using PowerShell

You can delete a SharePoint Online site from the recycle bin with the Remove-SPODeletedSite PowerShell cmdlet:

Remove-SPODeletedSite
      [-Confirm]
      -Identity <SpoSitePipeBind>
      [-NoWait]
      [-WhatIf]
      [<CommonParameters>]

Here is an example of how to delete a site permanently:

#Define Parameter values
$AdminSiteURL = "https://crescent-admin.sharepoint.com"
$DeletedSiteCollURL = "https://crescent.sharepoint.com/sites/DeletedSite"
 
#Connect to SharePoint Online
Connect-SPOService -url $AdminSiteURL -Credential (Get-Credential)

#Remove Deleted SharePoint Online Site Collection permanently
Remove-SPODeletedSite -identity $DeletedSiteCollURL -Confirm:$false

The deletion process may take a while, depending on the size of the site.

Permanently Delete All Site Collections from Recycle Bin in SharePoint Online:

Want to delete all sites from the recycle bin permanently? Here is the Windows PowerShell script to remove all deleted sites:

#Define Parameter values
$AdminSiteURL = "https://crescent-admin.sharepoint.com"
 
#Connect to SharePoint Online
Connect-SPOService -url $AdminSiteURL -Credential (Get-Credential)

#Permanently Remove all Deleted Sites
Get-SPODeletedSite | ForEach {
   Write-host "Deleting Site " $_.Url
   #sharepoint online powershell delete site from recycle bin
   Remove-SPODeletedSite -Identity $_.Url -Confirm:$False
}

This empties the tenant recycle bin in SharePoint Online. Here is another post on deleting SharePoint Online site collections: How to Delete a Site Collection in SharePoint Online using PowerShell?

SharePoint Online: Delete Site Collection from Recycle bin using PnP PowerShell

Let’s delete site collection from the recycle bin SharePoint Online using PnP PowerShell:

#Config Variables
$TenantURL = "https://Crescent.sharepoint.com"
$SiteURL = "https://Crescent.sharepoint.com/sites/Customers"

#Connect to PnP Online
Connect-PnPOnline -Url $TenantURL -Credentials (Get-Credential)

#Get the Deleted Site from Recycle Bin
$DeletedSite = Get-PnPTenantRecycleBinItem | Where {$_.URL -eq $SiteURL}

#Check if site exists in recycle bin
If($DeletedSite)
{
    #sharepoint online powershell delete site collection from recycle bin
    Clear-PnPTenantRecycleBinItem -Url $SiteURL -Force
    Write-host -f Green "Site '$SiteURL' Deleted from Recycle Bin Successfully!"
}
Else
{
    Write-host -f Yellow "Could not find Site '$SiteURL' in Recycle Bin!"
} 

Conclusion:

In this article, we’ve shown how to delete a site collection from the recycle bin in SharePoint Online using the SharePoint Online Admin Center and PowerShell. Following these steps, you can permanently delete a site collection from the recycle bin to free up storage space or for other reasons. It is important to note that permanently deleting a site collection is irreversible, so it should be done cautiously!

What happens when I delete a SharePoint site from the recycle bin?

When you delete a SharePoint site from the recycle bin, all the content, subsites, and associated resources within that site are permanently deleted. This action cannot be undone (unless you have a backup solution in place!), so it’s crucial to be cautious when deleting a site.

Who has permission to delete a SharePoint site?

To delete a SharePoint site, you must have site owner permissions or a site collection administrator. SharePoint Administrators can delete a site from the SharePoint Admin Center or PowerShell.

Can I recover a deleted SharePoint site?

Yes, SharePoint Online sites can be recovered from the site collection recycle bin by a site collection administrator within 93 days of deletion.

How do I delete a subsite in SharePoint?

To delete a subsite, navigate to the subsite you wish to delete, click on the site settings icon, and look for the “Site Actions” section where you’ll find the “Delete this site” option. Confirm your intention to delete when prompted.

Will deleting a SharePoint site affect my entire site collection?

Deleting a subsite within a site collection only removes that specific subsite and its contents. However, deleting the top-level site of a site collection will remove the entire site collection and all subsites within it. Always verify the scope of the site you are deleting.

How do I delete a SharePoint site from the admin center?

In the SharePoint Admin Center, you can delete sites by navigating to the “Active Sites” page, selecting the site or sites you want to delete, and choosing “Delete” from the menu.

Will deleting a SharePoint site free up storage space?

Yes, deleting a SharePoint site will free up storage space associated with that site. However, the deleted site and its content will remain in the recycle bin until the retention period expires or until they are permanently deleted from the recycle bin.

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!

2 thoughts on “SharePoint Online: Delete Site Collection from Recycle Bin using PowerShell

  • How to do this using Graph Powershell? I can’t seem to find a command that fits the purpose (Remove-MgDeletedSite or something).

    Reply
  • excellent write-up, thanks!

    Reply

Leave a Reply

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