Delete A SharePoint Online/O365 Site Using PowerShell And CSOM

Steps
  1. Open SharePoint Management Shell
  2. Copy the code given below and run it. 
  1. Add-Type -Path "c:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.dll"    
  2. Add-Type -Path "c:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"    
  3.    
  4. $siteUrl = “https://gowtham.sharepoint.com/tutorials/sitecollections/test1”  
  5. $username = "[email protected]"   
  6. $password = ""    
  7. $ctx = New-Object Microsoft.SharePoint.Client.ClientContext($siteUrl)    
  8. $credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($username, $password)    
  9. $ctx.Credentials = $credentials   
  10.    
  11. $web = $ctx.Web    
  12.    
  13. $ctx.Load($web)    
  14. $ctx.ExecuteQuery()   
  15.    
  16. $web.DeleteObject()   
  17. $ctx.ExecuteQuery()   
  18. Write-Host $web.Title "Site collection has been deleted"   
Thanks for reading my blog.