Friday, February 13, 2015

SharePoint Online: PowerShell to Delete Site Collection

Requirement: Delete SharePoint online Site Collection using PowerShell.

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

How to delete a SharePoint Online Site collection using PowerShell?
Here is the PowerShell script to for SharePoint online to delete site collection.
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!"

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 remove a site collection from recycle bin too, use: 
#Remove Deleted SharePoint Online Site Collection permanently
Remove-SPODeletedSite –identity $DeletedSiteCollURL -Confirm:$false

You might also like:
SharePoint Usage Reports
Usage reports, collaboration and audit for SharePoint.
Document SharePoint Farm
Automatically generate SharePoint documentation.

Check out these SharePoint products:

No comments :

Post a Comment

Please Login and comment to get your questions answered!

You might also like:

Related Posts Plugin for WordPress, Blogger...