There is a stage where an Office 365 group can reach its end. As O365 group acts a major role for may Office 365/Azure related workloads, there could be plenty of situations you come across that you have to get rid of some of your Office 365 Groups.
For instance, a situation where you have removed your Team and Its associated SharePoint site but Group object could be still hanging in the recycle bin until it reaches the retention period based on the retention policy you have set. Or, perhaps, you have decided to delete a SharePoint site or Microsoft Team, you will find you cannot create another team or site in its place. You will receive an error saying this group already exists. This is because the group was deleted as a ‘soft delete’. Meaning it’s sitting in a recycle bin for a number of days until it’s permanently deleted (retention plays again). Just follow these steps and you will immediately get rid of that unnecessary group object.
First and foremost, ensure that you have Azure AD PowerShell module is installed in your PC.
Run the following commands in sequence.
This first line will connect you to your Office 365 Tenant’s Azure AD. you will be prompted for the credentials to log in.
Connect-AzureAD
Now let’s run this one to get the group GUID from the deleted list
Get-AzureADMSDeletedGroup
Copy that GUID of the desired group and run the following by targeting that ID.
Remove-AzureADMSDeletedDirectoryObject -Id <ReplaceWithGroupID>
It should result as follows if it was success
To ensure the deletion is successful, run the same command again and see if it doesn’t return the group name you deleted. It shouldn’t !
Get-AzureADMSDeletedGroup