Share via


SharePoint 2013 and O365: Delete Site Collections from Recycle Bin

Step 1: Management PowerShell window

Open Management PowerShell window (ensure that SharePoint Windows Management PowerShell is successfully installed on your local machine).  If it is not installed: Please follow this link for Introduction/Installation guide for the SharePoint Online Management Shell: Click here for details

If it is installed: Press Windows button of your keyboard → type: Windows PowerShell ISE →  right-click on it → select: Run as Administrator            

Step 2: Remove site collections

Copy and paste the below PowerShell script into the SharePoint Windows Management Power Shell Window:

#---------Remove all site Collections from online Recyclebin---------------------------
 
Connect-SPOService -Url https://yourdomain-admin.sharepoint.com
 
$fromRecyclebin =  Get-SPODeletedSite 
foreach ($mySite in $fromRecyclebin)
{
    write-host $mySite.Url
 
    Remove-SPODeletedSite -Identity $mySite.Url-confirm:$false 
}
  #Hint: Select the above script and press F8. You will be prompted with a dialog for credentials. Put the tenant level admin credentials (email and password) and go ahead... 
 
#---------Remove desired/selected site Collections from online Recyclebin---------------------------
 
Connect-SPOService -Url https://yourdomain-admin.sharepoint.com
 
$csv = Import-Csv "D:\MySiteColls.csv"   
foreach ($site in $csv)  
{ 
    write-host $site.Url
    Remove-SPODeletedSite -Identity $site.Url -confirm:$false
} #Hint:Select the above script and press F8. You will be prompted with a dialog for credentials. Put the tenant level admin credentials (email and password) and go ahead...

Step 3: Verify CSV

The format of the CSV file should be as follows: