Friday, February 13, 2015

SharePoint Online: Delete Site Collection using PowerShell

Requirement: Delete SharePoint online Site Collection using PowerShell.

How to delete 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: https://YOURCOMPANY-admin.sharepoint.com/_layouts/15/online/SiteCollections.aspx )
  • 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.
Import-Module Microsoft.Online.Sharepoint.PowerShell

#Variables for processing
$AdminSiteURL = "https://crescent-admin.sharepoint.com/"
$AdminName = "salaudeen@crescent.onmicrosoft.com"
$SiteCollURL = "https://crescent.sharepoint.com/sites/Sales"

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

Tags: sharepoint online remove site collection powershell, powershell sharepoint online delete site collection, sharepoint online powershell delete site



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


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...