SharePoint Online: Delete a Site Collection using PowerShell

Requirement: Delete a SharePoint Online Site Collection using PowerShell.

How to Delete a Site Collection in SharePoint Online?

SharePoint Online site collection is a collection of one or more sites that are grouped under a common URL and typically share a common navigation, branding, features, security, etc. When it comes to managing content in SharePoint Online, you may at some point need to delete a site when you no longer need it. E.g., Project completed, a Temporary site, or maybe it was created mistakenly. Whatever the reason, you can delete a site in SharePoint Online to free up storage space and other resources by following the steps outlined in this tutorial.

As a SharePoint Online Site Admin, you can delete any SharePoint site in the tenant. This article will walk you through the process of deleting your site entirety, which includes all data, lists, libraries, and files associated with it. Before you begin this process, it’s a good idea to make sure that the site is no longer required. Deleting a site collection is quite a straightforward process. To delete a SharePoint Online site collection from the Admin center, follow the below steps:

  1. Login to your SharePoint Online Admin Center (Typically at
  2. Click on Sites >> Active Sites in the left navigation. From the site collections list, select the site collection to delete. From the Toolbar, click on “Delete” and then confirm by a prompt by clicking the “Delete” button in the command bar.
    delete sharepoint online site using powershell

If you selected an Office 365 group-connected site, you’d get a prompt with an option to delete the associated Office 365 group as well. Deleted sites are retained for 93 days in SharePoint Online, and then they will be permanently deleted automatically. However, the deleted Office 365 groups are kept for only 30 days in Azure AD Recycle Bin.

If you have site collection Admin rights, You can also delete a Modern team site collection or communication site by directly going to the site >> Click on Settings gear icon >> Site Information link >> Click on the Delete Site link! You can delete the site by clicking the settings icon >> site settings page and clicking on the “Delete this site” link on non-group connected, classic sites. Confirm the warning message prompt to delete the site!

how to delete a site in sharepoint online

This deletes all site contents, including document libraries, and list data associated with that particular SharePoint Online site within a few minutes, depending on how much data is deleted.

Delete Multiple Site Collections in SharePoint Online

Similarly, You can delete multiple SharePoint Online sites using the modern admin center by selecting more than one site collection >> Click on “Bulk Edit”>> Choose the “Delete” item in the menu and confirm the prompt!

delete multiple site collections in sharepoint online

Once deleted, You can find them under the “Deleted sites” link from the SharePoint Online admin center’s left navigation. Now, let’s delete a site collection in SharePoint Online with PowerShell!

How to Delete a SharePoint Online Site Collection using PowerShell?

Here is the PowerShell script for SharePoint Online to delete the site collection. Use SharePoint Online Management Shell or PowerShell ISE to run these cmdlets.

Import-Module Microsoft.Online.Sharepoint.PowerShell

#Variables for processing
$AdminSiteURL = ""
$AdminName = "[email protected]"
$SiteCollURL = ""

#Credentials to connect 
$SecurePWD = ConvertTo-SecureString "Password" -asplaintext -force  
$Credential = New-Object -TypeName System.Management.Automation.PSCredential -argumentlist $AdminName, $SecurePWD
#Connect to SharePoint Online
Connect-SPOService -url $AdminSiteURL -credential $Credential

#delete sharepoint online site collection using powershell
Remove-SPOSite -Identity $SiteCollURL -NoWait -Confirm:$false

Write-Host "Site collection has been deleted!"

SharePoint Online: Remove Site Collection with PowerShell

You can also use SharePoint Online Management Shell Remove-SPOsite PowerShell cmdlets to delete a SharePoint site collection:

$AdminSiteURL = ""
$SiteCollURL = ""

#Connect to sharepoint online
Connect-SPOService -url "" -credential (Get-Credential)

#sharepoint online powershell delete site collection
Remove-SPOSite -Identity $SiteCollURL -NoWait -Confirm:$false

This PowerShell deletes site collection in SharePoint Online. Please note, The Remove-SPOSite does not delete a site collection permanently. But it moves the site collection to the Recycle Bin.

Remove Site Collection using PowerShell CSOM

When you delete a SharePoint Online site, all subsites, pages, lists and libraries, and content within site are also deleted. Here is how to delete a site with a client-side object model PowerShell script:

#Load SharePoint CSOM Assemblies
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll"
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"
Add-Type -Path "C:\Program Files\SharePoint Online Management Shell\Microsoft.Online.SharePoint.PowerShell\Microsoft.Online.SharePoint.Client.Tenant.dll"

#delete site collection sharepoint online powershell
Function Remove-SPOSiteCollection($AdminCenterURL,$SiteURL)
    Try {
        #Setup Credentials to connect
        $Cred= Get-Credential
        #Setup the Context
        $Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($AdminCenterURL)
        $Ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Cred.Username, $Cred.Password)
        #Get the tenant object 
        $Tenant = New-Object Microsoft.Online.SharePoint.TenantAdministration.Tenant($Ctx)

        Write-Host -f Yellow "Deleting site collection..." 
        #delete a sharepoint online site powershell
        $Tenant.RemoveSite($SiteURL) | Out-null
        #$Tenant.RemoveDeletedSite($SiteURL) #To delete site from recycle bin!
        Write-host "Site Collection Deleted Successfully!" -foregroundcolor Green
    catch {
        write-host "Error: $($_.Exception.Message)" -foregroundcolor Red
#Set Parameters
$AdminCenterURL = ""
$SiteURL = ""

#Call the function to delete site collection
Remove-SPOSiteCollection $AdminCenterURL $SiteURL
Permissions to Delete a Site in SharePoint Online
To delete a SharePoint Online Site Collection, You need to be a Site Collection Administrator / SharePoint Online Admin / Global Admin!

What happens when a SharePoint site is deleted? Both the above PowerShell cmdlets and the web browser methods send the site collection to the recycle bin but don’t remove the site collection permanently.

Permanently Delete the SharePoint Online Site Collection

When you delete a site collection, it goes to the recycle bin. You may want to permanently delete that site collection to reuse the storage space or recreate a new site collection with the same URL. Because, If you try to create a site collection with a deleted site in the recycle bin, SharePoint gives you a message “The site address is available with modification” and doesn’t allow you to use the same URL!

powershell to delete sharepoint online site collection

How to Delete a Site Permanently in SharePoint Online?

How to permanently delete a SharePoint Online site? To delete a site collection permanently in SharePoint Online, Login to the new admin center site >> Click on “Deleted Sites” from the left navigation. This lists all deleted sites in the tenant within the past 93 days. Select the site to delete, click the “Permanently Delete” button in the Toolbar, and confirm the prompt.

sharepoint online permanently delete site collection powershell

However, if you try to permanently delete a modern Office 365 group site using the above steps, You’ll find the Permanently delete button is disabled! So the only way to permanently remove deleted Modern sites is PowerShell! Let’s delete a site collection in SharePoint Online using PowerShell:

SharePoint Online PowerShell to Delete Site Collection Permanently from Recycle bin

We can use PowerShell to remove a deleted site in SharePoint Online. To permanently delete site collection from recycle bin, use the below script in SharePoint Online Management Shell: 

$DeletedSiteCollURL = ""

#Remove Deleted SharePoint Online Site Collection permanently
Remove-SPODeletedSite -identity $DeletedSiteCollURL -Confirm:$false

This deletes the site from the recycle bin.

SharePoint Online PnP PowerShell to Delete Site Collection

Here is how to delete a particular site collection in SharePoint Online using PnP PowerShell

#Config Variables
$SiteURL = ""

#Get Credentials to connect
$Cred = Get-Credential

#Connect to PnP Online
Connect-PnPOnline -Url $SiteURL -Credentials $Cred
#sharepoint online delete site collection powershell
Remove-PnPTenantSite -Url $SiteURL -Force 

To permanently delete site collection with PnP PowerShell, use the -SkipRecycleBin switch.

Remove-PnPTenantSite -Url $SiteURL -Force -SkipRecycleBin

To remove a deleted site collection from recycle bin with PnP PowerShell, use the below cmdlet:

Remove-PnPTenantSite -Url $SiteURL -FromRecycleBin 

Removing stale content not only helps us to reduce storage costs, but also helps users to find the right content they’re looking for more quickly – as we remove unnecessary sites.

If you’ve accidentally deleted a SharePoint Online site, don’t worry – it can be restored within 93 days! Here are the necessary steps to restore a deleted site: How to Restore a Deleted Site in SharePoint Online?

Can I delete the Root site collection SharePoint Online?

No! You can’t delete the root site collection in SharePoint Online through SharePoint Admin Center. If you use other methods like PowerShell to delete, All other site collections and OneDrive will be inaccessible for all users until you either restore the site or create a new root site. Instead of deleting and recreating a SharePoint Online root site collection, you can use this method: How do you replace a classic root site in SharePoint online with a modern site?

How do I delete OneDrive for business collection in SharePoint online?

If you no longer need a OneDrive for Business site, you can delete it by navigating to the URL: and then click on the “Delete” button. Be sure you replace the “Tenant” and “UserLogin” placeholders in the URL accordingly.
More info: How to Delete OneDrive for Business Site Collection?

How do I delete a subsite in SharePoint Online using PowerShell?

To delete a SharePoint subsite with PnP PowerShell, use the Remove-PnPWeb cmdlet. You can also use the CSOM method $web.DeleteObject() to remove a subsite in SharePoint Online. Deleted subsites end up in the Site Collection’s Recycle bin (also called the second-stage Recycle Bin).
More info: Delete a subsite SharePoint Online

Salaudeen Rajack

Salaudeen Rajack - SharePoint Expert with Two decades of SharePoint Experience. Love to Share my knowledge and experience with the SharePoint community, through real-time articles!

2 thoughts on “SharePoint Online: Delete a Site Collection using PowerShell

  • Do I need Tenant admin roles to delete a site collection?

    • Site collection Administrators can delete a site from site settings page or with PnP PowerShell. However for SharePoint Online Admin Center or SPO cmdlets, You need to have “SharePoint Online Administrator” permission.


Leave a Reply

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