If you have been using SharePoint Online for a while, you will eventually end up with test sites, old project sites, or duplicate team sites that nobody uses anymore. These sites still consume storage, clutter your admin center, and can confuse users. The good news is that you can clean these up very quickly using PowerShell.
In this tutorial, I will walk you through how to delete a SharePoint Online site using PowerShell, step by step. We will use both the SharePoint Online Management Shell and PnP PowerShell, and we will also look at how to delete multiple sites in bulk. I will also cover a few safety tips and common issues so you don’t accidentally delete the wrong site.
By the end of this tutorial, you will know how to:
- Delete a single SharePoint Online site using the SharePoint Online Management Shell.
- Permanently delete a site from the SharePoint recycle bin using PowerShell.
- Delete Microsoft 365 group–connected sites.
- Delete a site using PnP PowerShell (with options to send to recycle bin or skip it).
- Delete multiple sites in one go using both modules.
We will keep the examples simple so you can copy–paste and adapt them easily.
Prerequisites and Permissions
Before running any scripts, make sure you have the right setup and permissions to delete a SharePoint site.
To delete a SharePoint Online site using PowerShell, you need:
- SharePoint Administrator or Global Administrator in Microsoft 365.
- Site collection administrator (or at least full control) on the site, especially for some admin actions.
If you are only a SharePoint admin but not a site owner or member, you may see permission errors when trying to delete some sites.
Install required modules
- SharePoint Online Management Shell
Install (or update) the module from PowerShell:
Install-Module -Name Microsoft.Online.SharePoint.PowerShell -Scope CurrentUserOr update it:
Update-Module -Name Microsoft.Online.SharePoint.PowerShell- PnP PowerShell
Install PnP PowerShell using the below cmdlets:
Install-Module -Name PnP.PowerShell -Scope CurrentUserOr update:
Update-Module -Name PnP.PowerShellConnect to your tenant
You will need your SharePoint admin center URL in the format:
https://<tenant>-admin.sharepoint.comFor example:
Connect-SPOService -Url "https://szg52-admin.sharepoint.com"
You will be prompted to sign in with your admin account.
For PnP PowerShell:
Connect-PnPOnline -Url "https://szg52-admin.sharepoint.com" -Interactive
Check out Get SharePoint Site Members Using PowerShell
Understanding How Deletion Works in SharePoint Online
Before deleting anything, it helps to understand what actually happens when you remove a site.
- When you use
Remove-SPOSite, the site is moved from Active sites to Deleted sites (Recycle bin) in the SharePoint admin center. - The site stays in the Deleted sites list for 93 days (default) unless you delete it permanently earlier using
Remove-SPODeletedSite. - PnP PowerShell
Remove-PnPTenantSitebehaves similarly by default (moves to recycle bin) and can also skip the recycle bin.
So you typically have two stages:
- Send the site to the recycle bin.
- Permanently remove it from the recycle bin (optional but often recommended for cleanup).
This is good from a safety point of view because you can restore a site if you deleted it by mistake (as long as it is still in Deleted sites).
Read Get Site Template in SharePoint Using PowerShell
Delete a SharePoint site using SharePoint Online Management Shell
Let’s start with the standard Microsoft module.
Cmdlets you will use
Remove-SPOSite– moves the site to the SharePoint Online recycle bin (Deleted sites).Remove-SPODeletedSite– permanently deletes a site from the recycle bin.
You can run these in Windows PowerShell, PowerShell 7, PowerShell ISE, or VS Code.
1. Delete a single SharePoint site using Remove-SPOSite
Syntax (simplified):
Here is the simplified syntax of deleting a single SharePoint site using the Remove-SPOSite.
Remove-SPOSite -Identity <SiteUrl> [-Confirm] [-NoWait] [-WhatIf]Key parameters in simple language:
-Identity– the full URL of the site you want to delete.-Confirm– asks for confirmation before deleting the site.-NoWait– does not wait for the operation to finish; the script continues immediately.-WhatIf– shows what would happen if the command runs, without actually deleting anything.
Example 1: Delete a SharePoint site and move it to recycle bin
Connect-SPOService -Url "https://szg52-admin.sharepoint.com"
Remove-SPOSite -Identity "https://szg52.sharepoint.com/sites/ProjectSite"When you run this, PowerShell will ask for confirmation.
Type Y / choose Yes to delete, or N / No to cancel. Here is a screenshot for your reference.

After deletion:
- Go to SharePoint admin center → Sites → Deleted sites to see the site listed there.
Example 2: Force confirmation prompt
If you want to ensure it always prompts:
Remove-SPOSite -Identity "https://szg52.sharepoint.com/sites/AdminTeam" -ConfirmYou will get a confirmation prompt before the site is moved to Deleted sites.
Here is a screenshot for your reference.

Example 3: Delete without waiting
If you are running a script and do not want to wait until the operation finishes:
Remove-SPOSite -Identity "https://szg52.sharepoint.com/sites/DatabaseTeam" -NoWaitPowerShell returns control to you quickly, while deletion continues in the background. You can see the exact output in the screenshot below:

Example 4: Preview what will happen with WhatIf
This is useful when you are not 100% sure and want to double–check the URL.
Remove-SPOSite -Identity "https://szg52.sharepoint.com/sites/DeereandCompany" -WhatIfYou will see a message like:
Performing the operation “Remove-SPOSite” on target “https://szg52.sharepoint.com/sites/DeereandCompany”.
No actual deletion happens when you use -WhatIf.
You can see the exact output in the screenshot below:

Tip: Use -WhatIf first when working with scripts that target multiple SharePoint sites.
Check out Get All SharePoint Site Collections Using PowerShell
Permanently Delete a SharePoint Site from Deleted Sites
After a site is removed with Remove-SPOSite, it sits in the SharePoint recycle bin. If you are sure you no longer need it, you can permanently delete it using Remove-SPODeletedSite.
Syntax (simplified):
Remove-SPODeletedSite -Identity <SiteUrl> [-NoWait] [-WhatIf] [-Confirm]Example: Permanently delete a SharePoint site from recycle bin
Connect-SPOService -Url "https://szg52-admin.sharepoint.com"
Remove-SPODeletedSite -Identity "https://szg52.sharepoint.com/sites/ProjectSite" -NoWaitYou may get a confirmation prompt depending on your settings; confirm to complete the deletion. After this, the site cannot be restored from the SharePoint recycle bin.

Delete Microsoft 365 Group–Connected SharePoint Sites
Modern team sites are often connected to Microsoft 365 groups. When you try to delete such a site using Remove-SPOSite, you may get an error like:
“This site belongs to a Microsoft 365 group. To delete the site, you must delete the group.”
You have a few options here.
Option 1: Delete the Microsoft 365 group (recommended)
If you no longer need the associated group (Teams, Planner, mailbox, etc.), you should delete the group. You can do this from:
- Microsoft 365 admin center → Groups → Active groups → Select group → Delete.
- Or via PowerShell using Azure AD / Microsoft Graph modules (beyond this article’s scope).
When you delete the group, the connected SharePoint site is also removed.
Option 2: Delete only the SharePoint site using Remove-SPODeletedSite
In some cases, Remove-SPODeletedSite can remove the group–connected site from the Deleted sites list but will not delete the underlying group.
Connect-SPOService -Url "https://szg52-admin.sharepoint.com"
Remove-SPODeletedSite -Identity "https://szg52.sharepoint.com/sites/hiringTeam"Note:
- This removes the site, but the Microsoft 365 group may still exist and appear elsewhere in Microsoft 365.
Check out Add SharePoint Online List Items Using PowerShell
Delete a SharePoint site using PnP PowerShell
PnP PowerShell is very popular among SharePoint admins because it is more flexible and often easier to script.
The main cmdlet you will use is:
Remove-PnPTenantSite– deletes a site collection from your tenant, with options to send it to or skip the recycle bin.
Syntax (simplified):
Remove-PnPTenantSite -Url <SiteUrl> [-FromRecycleBin] [-SkipRecycleBin] [-Force]Key parameters:
-Url– full site URL.-FromRecycleBin– deletes the site from the recycle bin (permanent).-SkipRecycleBin– deletes the site permanently without sending it to recycle bin.-Force– suppresses confirmation prompts.
1. Delete a SharePoint Site and Move it to Recycle Bin
Connect-PnPOnline -Url "https://szg52-admin.sharepoint.com" -Interactive
Remove-PnPTenantSite -Url "https://szg52.sharepoint.com/sites/ResourceDevelopment"You will be prompted:
Are you sure you want to remove the site? (Y/N)
Type Y to confirm.
The site is then moved to the SharePoint Deleted sites (recycle bin). Here is the exact output in the screenshot below:

2. Permanently Delete a SharePoint Site from Recycle Bin
If the SharePoint site is already in the recycle bin and you want to remove it permanently:
Remove-PnPTenantSite -Url "https://szg52.sharepoint.com/sites/ResourceDevelopment" -FromRecycleBinAgain, you will be asked for confirmation; confirm to complete deletion.
Here is the exact output in the screenshot below:

3. Delete a SharePoint Site and Skip the Recycle Bin
If you are absolutely sure and want to skip the recycle bin entirely:
Remove-PnPTenantSite -Url "https://szg52.sharepoint.com/sites/AccountManagement" -SkipRecycleBinYou can combine -SkipRecycleBin with -Force to avoid prompts (use with extra care):
Remove-PnPTenantSite -Url "https://szg52.sharepoint.com/sites/AccountManagement" -SkipRecycleBin -Force
Read The Term Get-SPweb Is Not Recognized As The Name Of A Cmdlet Function Script File
Delete Multiple SharePoint Sites using PowerShell
If you have a list of old sites to clean up, doing it one by one from the UI is painful. PowerShell makes bulk deletion much easier.
Using SharePoint Online Management Shell (Remove-SPOSite)
You can store the SharePoint site URLs in an array and loop through them.
Connect-SPOService -Url "https://szg52-admin.sharepoint.com"
$siteUrls = @(
"https://szg52.sharepoint.com/sites/Admin",
"https://szg52.sharepoint.com/sites/DeereandCompany"
)
foreach ($url in $siteUrls) {
Write-Host "Deleting site: $url"
Remove-SPOSite -Identity $url -Confirm:$false
}What this does:
- Loops through each URL in
$siteUrls. - Deletes the site without asking for confirmation (because
-Confirm:$falseis used). - Moves all these sites to Deleted sites.
You can later run Remove-SPODeletedSite individually or in a similar loop if you want to permanently delete them.
Using PnP PowerShell (Remove-PnPTenantSite)
Similarly, with PnP:
Connect-PnPOnline -Url "https://szg52-admin.sharepoint.com" -Interactive
$siteUrls = @(
"https://szg52.sharepoint.com/sites/DeereandCompany",
"https://szg52.sharepoint.com/sites/SharePointteam"
# Add more site URLs as needed
)
foreach ($siteUrl in $siteUrls) {
Write-Host "Deleting site: $siteUrl"
Remove-PnPTenantSite -Url $siteUrl
}You will see confirmation prompts for each site.
If you are running this in a controlled scenario and want to skip prompts, you can use -Force and optionally -SkipRecycleBin.
Example:
foreach ($siteUrl in $siteUrls) {
Write-Host "Permanently deleting site: $siteUrl"
Remove-PnPTenantSite -Url $siteUrl -SkipRecycleBin -Force
}Use this only when you are 100% sure, because there is no recycle bin to fall back on.

Best Practices
Here are some best practices that you can follow while deleting a SharePoint site using PowerShell.
- Always double–check the site URL before deleting, especially in scripts or loops.
- Start with
-WhatIf(forRemove-SPOSite) on new scripts to see what would happen without actually deleting anything. - Keep a copy of your site URL list (for bulk deletes) in a CSV or text file for audit and rollback planning.
- If you are unsure whether a site is still in use, check Last activity, Storage used, or confirm with the business owner before deletion.
- Avoid using
-SkipRecycleBinin production unless you have a clear backup or retention strategy.
A simple way to reduce mistakes is:
- First, move sites to the recycle bin.
- Wait for a short “cooling period” (a few days or weeks).
- Then permanently delete them only if there are no complaints or restore requests.
Here is a summary of various methods to use while deleting SharePoint sites.
| Task | Module | Command / Example |
|---|---|---|
| Connect to SharePoint admin center | SharePoint Online Mgmt Shell | Connect-SPOService -Url "https://tenant-admin.sharepoint.com" |
| Delete site (move to recycle bin) | SharePoint Online Mgmt Shell | Remove-SPOSite -Identity "<siteUrl>" |
| Preview delete without changes | SharePoint Online Mgmt Shell | Remove-SPOSite -Identity "<siteUrl>" -WhatIf |
| Permanently delete from recycle bin | SharePoint Online Mgmt Shell | Remove-SPODeletedSite -Identity "<siteUrl>" |
| Connect with PnP | PnP PowerShell | Connect-PnPOnline -Url "https://tenant-admin.sharepoint.com" -Interactive |
| Delete site (to recycle bin) | PnP PowerShell | Remove-PnPTenantSite -Url "<siteUrl>" |
| Delete site from recycle bin | PnP PowerShell | Remove-PnPTenantSite -Url "<siteUrl>" -FromRecycleBin |
| Delete site and skip recycle bin | PnP PowerShell | Remove-PnPTenantSite -Url "<siteUrl>" -SkipRecycleBin -Force |
| Bulk delete sites (to recycle bin) | SharePoint Online Mgmt Shell | Loop with Remove-SPOSite -Identity $url -Confirm:$false |
| Bulk delete sites (PnP, flexible) | PnP PowerShell | Loop with Remove-PnPTenantSite -Url $siteUrl [-SkipRecycleBin] [-Force] |
I hope this tutorial helps you learning how to delete SharePoint sites using PowerShell or PnP PowerShell.
You may also like the following tutorials:
- How to Get SharePoint List Name using PowerShell?
- Get SharePoint Site Storage Size Using PowerShell
- Get the SharePoint Site Owner Using PowerShell
- Enable Item-level Permissions in a SharePoint Document Library Using PowerShell

After working for more than 18 years in Microsoft technologies like SharePoint, Microsoft 365, and Power Platform (Power Apps, Power Automate, and Power BI), I thought will share my SharePoint expertise knowledge with the world. Our audiences are from the United States, Canada, the United Kingdom, Australia, New Zealand, etc. For my expertise knowledge and SharePoint tutorials, Microsoft has been awarded a Microsoft SharePoint MVP (12 times). I have also worked in companies like HP, TCS, KPIT, etc.