This Microsoft SharePoint Online blog post will show how to delete a SharePoint site using PowerShell.
In some use cases, like deleting a Microsoft Teams channel site, we must use the SharePoint Online PowerShell module. Sometimes, we can use PowerShell to delete multiple sites at once.
Note: Before using the code, ensure the SharePoint Online PowerShell module is installed.
The following code will connect to SharePoint Online, using MFA and delete a site. In the $siteurl variable, add the site URL you need to delete and add your tenant name to the connect command.
# Site to delete
$siteurl = “https://SITEURL”
# Connecto to SharePoint using MFA
connect-sposervice -url “https://TENANTNAME-admin.sharepoint.com”
# Delete site
remove-sposite -Identity $siteurl -Nowait -confirm:$false