Permanently Remove a Site Collection from SharePoint Online Admin Recycle Bin

When deleting a site collection from your SharePoint Online tenant in the SharePoint Online Admin Center, by default a deleted site collection will stay in the recycle bin for 30 days. This is great as a retention policy for many reasons, but there is no easy way to then clear your recycle bin, or at least remove a site collection from the recycle bin.

This can be done using SharePoint Online PowerShell commandlets though.

Remove-SPODeletedSite

The magic comes from a simple command, Remove-SPODeleteSite, which will remove a site collection from the recycle bin.

My standard script:

1
2
3
4
5
6
7
$username = "eoverfield@"mytenant".onmicrosoft.com"
$password = "**mypassword**"
$cred = New-Object -TypeName System.Management.Automation.PSCredential -argumentlist $userName, $(convertto-securestring $Password -asplaintext -force)

Connect-SPOService -Url https://"mytenant"-admin.sharepoint.com/ -Credential $cred

Remove-SPODeletedSite -Identity https://"mytenant".sharepoint.com/sites/"deleted-site"

That is about it. Replace the username and password variables with your tenant admin account (yes, you need tenant admin access here), provide your SharePoint Admin site url and when using the Remove-SPODeletedSite command, provide the site collection url you already deleted and is not sitting in the recycle bin.

Once you run these commands, your site collection should be completely gone and the site collection url may be re-used.

Comments

  1. Duane Alleman says:

    Do you full Tenant admin role or will this script work if you are setup with only the SharePoint Admin role (not Tenant Admin)?

    Thanks!

  2. When I run this against a site sitting in our RecycleBin (copy/paste the url right from the RB), I get an error

    “Unable to find the deleted site: ___”

Speak Your Mind

*