SharePoint Online Site Deletion & URL Release

PowerShell | Soft Delete vs. Permanent Delete

Why You'd Release a SharePoint URL

Deleting a SharePoint site removes it from the Recycle Bin, but its URL usually isn't reusable until it's permanently purged. This most often comes up when rebuilding a site from scratch under the same address, or fully decommissioning a project or team site.

There are two ways to approach this — and the difference between them matters a lot if you make a mistake.

SharePoint Online site deletion and URL release with PowerShell
Requires: SharePoint Online Management Shell (download here) and SharePoint Admin or Global Admin rights. This module runs on Windows PowerShell 5.1, not PowerShell 7.
Read This Before You Delete Anything
  • If the site is connected to a Microsoft 365 Group or a Team, do not delete it directly with Remove-SPOSite. Group-connected sites are tied to the group's lifecycle — delete the Microsoft 365 Group instead (via Remove-UnifiedGroup or the admin center), which removes the site correctly along with its mailbox, calendar, and other connected resources.
  • Permanently purging a site cannot be undone. Once you run Remove-SPODeletedSite, there is no recovery — not from Microsoft support, not from a backup unless you have a dedicated third-party backup solution.

Before You Delete: Check the Site

Confirm you're targeting the right site and see whether it's connected to a Microsoft 365 Group (a non-empty GroupId means it is):

Connect-SPOService -Url "https://<your-tenant-name>-admin.sharepoint.com"

Get-SPOSite -Identity "https://<your-tenant-name>.sharepoint.com/sites/YourSiteName" |
    Select-Object Url, Title, Template, GroupId, Status

Method 1: Soft Delete Recommended Default

This moves the site to the Recycle Bin. The URL is not released yet, but the site is fully recoverable during the retention window (93 days by default) if you change your mind:

$SiteUrl = "https://<your-tenant-name>.sharepoint.com/sites/YourSiteName"

Remove-SPOSite -Identity $SiteUrl -Confirm:$false

Write-Host "Site sent to Recycle Bin: $SiteUrl"

Changed your mind? Restore it before the retention window expires:

Restore-SPODeletedSite -Identity $SiteUrl

Method 2: Permanently Delete & Release the URL Irreversible

Only do this once you're certain you no longer need the site or its content. This purges the site from the Recycle Bin immediately, making the URL available for reuse right away:

$AdminUrl = "https://<your-tenant-name>-admin.sharepoint.com"
$SiteUrl  = "https://<your-tenant-name>.sharepoint.com/sites/YourSiteName"

Connect-SPOService -Url $AdminUrl

# Step 1: Soft-delete the site (skip if already done via Method 1)
Remove-SPOSite -Identity $SiteUrl -Confirm:$false

# Step 2: Permanently purge it from the Recycle Bin, releasing the URL
Remove-SPODeletedSite -Identity $SiteUrl -Confirm:$false

Write-Host "Site permanently deleted and URL released: $SiteUrl"

Replace <your-tenant-name> and YourSiteName with your actual tenant name and site name before running.

Troubleshooting & Notes
  • The SharePoint Online Management Shell only works reliably in Windows PowerShell 5.1. If commands fail in PowerShell 7, reopen a Windows PowerShell 5.1 session.
  • If Remove-SPOSite fails with a message about the site being group-connected, stop and delete the Microsoft 365 Group instead.
  • URL release isn't always instantaneous after Remove-SPODeletedSite — allow a short delay before recreating a site at the same address.
  • Site collection administrators can't run these cmdlets on their own — you need SharePoint Admin or Global Admin rights in Microsoft 365.

When using any software or code, it is important to remember that there is always a certain level of risk involved. As a user, you are responsible for ensuring that the software or code you are using is suitable for your needs and that you are aware of any potential risks associated with its use.

If you are considering using any code or software provided by ITMS, we advise you to review our terms of service at https://www.itms-us.com/Website-Terms-Of-Use.

Any code provided by ITMS is provided "as is," without warranties or guarantees. By using our code, you acknowledge and accept the risks associated with its use and agree to hold ITMS harmless for any damages or losses that may result.

Let Us Manage Your Microsoft 365 Tenant

From SharePoint governance to full tenant management, IT Master Services keeps your Microsoft 365 environment clean, secure, and running the way it should.

Microsoft 365 Services