kwizcom banner advertisement

SharePoint Online: Delete Site Collection using PowerShell

Requirement: Delete SharePoint online Site Collection using PowerShell.

How to delete a site collection in SharePoint Online?
To delete a SharePoint online site collection from Admin center, follow below steps:
  • Login to your SharePoint online Admin Center (typically: )
  • From the site collections list, select the site collection to delete. From the ribbon, click on "Delete" and then confirm by prompt by clicking "Delete" button.
    powershell to delete sharepoint online site collection
Now, lets delete 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 site collection. use PowerShell ISE to run these cmdlets.
Import-Module Microsoft.Online.Sharepoint.PowerShell

#Variables for processing
$AdminSiteURL = ""
$AdminName = ""
$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
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 to delete site collection:
$AdminSiteURL = ""
$SiteCollURL = ""

Connect-SPOService -url "" -credential (Get-Credential)

#Delete SharePoint Online Site Collection
Remove-SPOSite -Identity $SiteCollURL -NoWait -Confirm:$false
This PowerShell deletes site collection in SharePoint online.

To Delete a SharePoint Online Site Collection, You need to be a Site Collection Administrator / SharePoint Online Admin / Global Admin!

Permanently Delete the SharePoint Online Site Collection:
When you delete a site collection, it goes to 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.
SharePoint Online PowerShell to Delete Site Collection

SharePoint online PowerShell to delete site collection permanently from Recycle bin
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 site from recycle bin.
SharePoint Online: Delete Site Collection using PowerShell SharePoint Online: Delete Site Collection using PowerShell Reviewed by Salaudeen Rajack on February 13, 2015 Rating: 5

No comments:

Please Login and comment to get your questions answered!

Powered by Blogger.