Completely decommission unused M365 Groups or Teams linked components

EnterpriseArchitect 5,136 Reputation points
2023-12-05T04:15:45.04+00:00

When we create Microsoft Teams or M365 Groups, there are some other objects created like Exchange Online shared mailbox, SharePoint site and Teams channel.

User's image

How can I decommission or delete those related objects based on empty cloud-only group deletion?

My goal here is to completely delete unused M365 Groups or Teams based on the empty cloud-only group in Azure Portal.

Any help or script to do this would be greatly appreciated.

Microsoft Teams
Microsoft Teams
A Microsoft customizable chat-based workspace.
9,588 questions
Microsoft Exchange Online Management
Microsoft Exchange Online Management
Microsoft Exchange Online: A Microsoft email and calendaring hosted service.Management: The act or process of organizing, handling, directing or controlling something.
4,373 questions
SharePoint Server Management
SharePoint Server Management
SharePoint Server: A family of Microsoft on-premises document management and storage systems.Management: The act or process of organizing, handling, directing or controlling something.
2,893 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Ling Zhou_MSFT 15,320 Reputation points Microsoft Vendor
    2023-12-05T08:53:41.15+00:00

    Hi @EnterpriseArchitect,

    Thank you for posting in this community.

    We can't delete Exchange Online shared mailbox, SharePoint site and Teams channel when you create Microsoft Teams or M365 Groups. These have to be created, if these objects are deleted then the group is also deleted.

    User's image

    User's image

    Permanently Delete M365 Group using Azure AD PowerShell?

    1.Install Azure Active Directory Module.

    2.let’s remove a Microsoft 365 group by its Email ID with the help of the Azure Active Directory PowerShell module:

    #Parameters
    $GroupEmail = "Purchase@Crescent.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
        }
    }
    Else
    {
        Write-host -f Yellow "Could not find Group with Email $GroupEmail!"
    }
    

    3.Retrieve deleted groups using: Get-AzureADMSDeletedGroup cmdlet. This returns all deleted groups with their IDs.

    4.Now, you can permanently remove the deleted group using the group ID. E.g. Remove-AzureADMSDeletedDirectoryObject -id 22bdc734-251f-48db-8030-19eb5560ddc3

    permanently delete office 365 group powershell


    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.


  2. Ling Zhou_MSFT 15,320 Reputation points Microsoft Vendor
    2023-12-11T06:07:41.7666667+00:00

    Hi @EnterpriseArchitect,

    I am kindly following up to see if you have any remaining questions or concerns for this issue. Please feel free to reach us if any questions or concerns you may have. If the answer is helpful, please click "Accept Answer" and kindly upvote it. By doing so, it will benefit all community members who are having this similar issue. Your contribution is highly appreciated.