When you delete a Microsoft 365 group, all group resources, including SharePoint site, mailbox conversations, Teams, notebook, and Planner tasks also get deleted. So, to delete a SharePoint group connected site, you must need to delete the Microsoft 365 group first.
Here are four methods to delete a Microsoft 365 group.
1.Go to Microsoft 365 admin center -> Active teams &groups -> Delete the Microsoft 365 group.
2.Use PNP PowerShell.
$AdminSiteURL = "https://tenant-admin.sharepoint.com"
$GroupEmail = "Group@tenant.onmicrosoft.com"
Connect-PnPOnline -Url $AdminSiteURL -Interactive
$Group = Get-PnPMicrosoft365Group | Where Mail -eq $GroupEmail
Remove-PnPMicrosoft365Group -Identity $Group.id
Write-host "Group Deleted Successfully!" -f Green
3.Use Exchange PowerShell.
Connect-ExchangeOnline -ShowBanner:$False
Remove-UnifiedGroup -Identity "Group@tenant.onmicrosoft.com"
Disconnect-ExchangeOnline -Confirm:$False
4.Use Azure AD PowerShell.
#Parameters
$GroupEmail = "Group@tenant.onmicrosoft.com"
#Connect to AzureAD
Connect-AzureAD -Credential (Get-Credential) | Out-Null
#Get the Azure AD Group
$Group = Get-AzureADGroup -Filter "Mail eq '$GroupEmail'"
If($Group)
{
$Prompt = Read-Host "Are you sure want to delete the Group (Y/N)?"
If($Prompt -eq "Y")
{
#Delete the Office 365 Group
Remove-AzureADGroup -ObjectId $Group.ObjectId
Write-Host "Group Deleted Successfully!" -f Green
}
}
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.