How to delete a SharePoint Site in SharePoint Online using Powershell?
Hello SharePointers,
Below is the Powershell command to delete a SharePoint site in Online/Office 365 using Powershell
Add-Type -Path “c:\folder\Microsoft.SharePoint.Client.dll”
Add-Type -Path “c:\folder\Microsoft.SharePoint.Client.Runtime.dll”
$siteUrl = “https://myoffice.sharepoint.com/sites/mysites”
$password = Read-Host -Prompt “Enter password” -AsSecureString
$context = New-Object Microsoft.SharePoint.Client.ClientContext($siteUrl)
$credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials(“admin@myoffice.onmicrosoft.com”, $password)
$context.Credentials = $credentials
$web = $context.Web
$ctx.Load($web)
$context.ExecuteQuery()
$web.DeleteObject()
$ctx.ExecuteQuery()
Write-Host $web.Title “Site Deleted”
Happy Sharepointing!!