Delete Office 365 Group Site Collection using PowerShell

Requirement: Delete office 365 group-connected site collection.

How to Delete Office 365 Group Site?
When you delete an Office 365 group, its associated team site gets deleted automatically (However, It takes a while up to 30 min to delete connected SharePoint Online site and clear it from "Active Sites" list in SharePoint Online Admin Center, in my experience!). Even when the group is deleted permanently or reaches 30 days from deletion, its SharePoint site waits for 92 days retention period before purged from recycle bin. So, How to delete Office 365 group sites immediately?

PowerShell to Delete Office 365 Group Site Collection
What if you delete an Office 365 group and the connected SharePoint Site doesn't get Deleted even after hours of waiting?
#Parameters
$AdminCenterURL="https://CrescentTech-Admin.SharePoint.com"
$GroupSiteURL="https://CrescentTech.SharePoint.com/sites/customers"
$OwnerLoginID = "Salaudeen@TheCrescentTech.com"

#Connect to SharePoint Online
Connect-SPOService -Url $AdminCenterURL

#Unlock the Group site Collection
Set-SPOSite -Identity $GroupSiteURL -LockState Unlock

#Set the Site Owner for Group Site
Set-SPOSite -Identity $GroupSiteURL -owner $OwnerLoginID

#Delete the Office 365 group site
Remove-SPOSite -Identity $GroupSiteURL -NoWait -Confirm:$false

Permanently Delete Office 365 Group SharePoint Site using PowerShell
To permanently delete office 365 group site, use this PowerShell script in SharePoint Online Management Shell.

Step 1: Connect to SharePoint Online
Connect-SPOService -Url https://crescenttech-admin.sharepoint.com

Step 2: Get the List of Deleted SharePoint Online Sites
Get-SPODeletedSite

Step 3: Delete the Office 365 Group site Permanently
Remove-SPODeletedSite -identity https://crescenttech.sharepoint.com/sites/customers

This deletes Office 365 group site collection and the problem of unable to create the Office 365 site  as there is already a site with same URL is resolved!
Delete Office 365 Group Site Collection using PowerShell Delete Office 365 Group Site Collection using PowerShell Reviewed by Salaudeen Rajack on May 06, 2018 Rating: 5

No comments:

Please Login and comment to get your questions answered!

Powered by Blogger.