Deleting a SharePoint Online Site Using PowerShell

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.

PowerShell Code

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


Posted

in

,

by

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.