Delete a Site Collection in SharePoint Online / Office 365

As my training is going on with SharePoint Online. I have created many site collection in my training period. Due to that, I want to delete couple of unused site collection. I written a PowerShell script to delete my unused site collection. Then I thought to share my script so that one can get help, if required. We can easily accomplish this by using the Remove-SPOSite cmdlet. When this cmdlet finishes the Site Collection will have been moved to the recycle bin and not actually deleted.

So we have two option, whether we want to delete the site permanently or recover it. If we wish to permanently delete the Site Collection (remove it from the recycle bin) then we must use the Remove-SPODeletedSite cmdlet
.Please find the following script to delete “Kirti” site collection.

Script:

  • Connect to SharePoint Online by using the following PowerShell command. It takes the URL of our tenant admin and a username. Then it will ask for password.
    1. Connect-SPOService -Url https://moharanakirti-admin.sharepoint.com -Credential [email protected]  
  • Move the Site Collection to recycle bin.
    1. Remove-SPOSite https://moharanakirti.sharepoint.com/sites/kirti -Confirm:$false  


  • Type y if we want to proceed with the command. Now the site will move to recycle bin as following image.

     

  • Now if we want to delete the site permanently, need to run the following command.
    1. Remove-SPODeletedSite -Identity https://moharanakirti.sharepoint.com/sites/kirti -Confirm: $false  

Both the Remove-SPOSite cmdlets accept a -NoWait parameter which you can provide to tell the cmdlet to return immediately.

Hope this will help.I will continue with recover the deleted site in my next blog. 
Ebook Download
View all
Learn
View all