kwizcom banner advertisement

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. use PowerShell ISE to run these cmdlets.
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!"

SharePoint Online: Remove Site Collection with PowerShell
You can also use SharePoint Online Management Shell to delete site collection:
#Variables
AdminSiteURL = "https://crescent-admin.sharepoint.com/"
$SiteCollURL = "https://crescent.sharepoint.com/sites/testitgroup"

#connect
Connect-SPOService -url "https://crescent-admin.sharepoint.com/" -credential (Get-Credential)

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

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