How to automate cleaning up unused Microsoft Teams

Teams that are never used are common, especially in organizations with a large number of teams. This can occur for a variety of reasons, including product testing, short-term team collaboration, or team owners leaving the organization. Such teams can accumulate over time and place a strain on tenant resources. As an administrator, we can use Microsoft 365 group expiration policy to automatically clean up unused teams to reduce the number of unused teams. Because teams are supported by groups, group expiration policies apply to teams as well. When we apply an expiration policy to a team, the team owner is notified 30 days, 15 days, and 1 day before the team’s expiration date. When the team owner receives the notification, they can renew the team by clicking renew now in team settings. If the team owner does not renew the team and there is no further activity on the team until the expiration policy expires, the team is “soft-deleted,” meaning it can be restored within the next 30 days. It is possible that a team owner will be unable to renew the team because they forgot to renew or were away when the renewal was due. A team in active use may be deleted in these scenarios due to the team’s expiration policies. Auto-renewal is enabled for a team in the group expiration policy to prevent accidental deletion. When the group expiration policy is enabled, any team that receives at least one channel visit from any team member before its end date is automatically renewed without the team owner’s intervention. For example, consider an expiration policy that states that a group will be deleted after 30 days of inactivity. However, because there is no record activity on the day that group expiration is enabled, Azure AD waits five days before sending an expiration email. If there is an activity within those five days, the expiration policy operates normally. We send an expiration/renewal email if there is no activity within five days. Of course, if the group was inactive for five days, an email was sent, and the group then became active, we will auto-renew it and restart the expiration period. The group that supports the team is renewed first, followed by the team itself. A new expiry date for the group is set as part of the renewal process. This new date may not be visible in Teams right away. Syncing can take up to 24 hours. So, In case you notice a difference in the expiry date of a team and its underlying group, wait 24 hours, after that you may be contacting support. The following user actions cause automatic group renewal:

SharePoint: View, edit, download, move, share, or upload files

  • Outlook: Join group, read/write group message from group space, Like a message (in Outlook Web Access)
  • Teams: Visit a Teams channel
  • Yammer: View a post within a Yammer community or an interactive email in Outlook

Let’s go over how to manage the lifecycle of Microsoft 365 groups by assigning them an expiration date. Only Microsoft 365 groups can have expiration policies set in Azure Active Directory (Azure AD), which is now part of Microsoft Entra.

Let’s sum up what about setting an expiration date for a group:

  • As the expiration date approaches, groups with user activities are automatically renewed.
  • If the group is not auto-renewed, the owners are notified to renew it.
  • Any unrenewed groups are deleted.
  • Any deleted Microsoft 365 group can be restored within 30 days by the group owners or the administrator.
  • For the time being, only one expiration policy can be set for all Microsoft 365 groups in an Azure AD organization.

How to get a list of automatically renewed groups

We have to open the Audit logs from Azure Active Directory and choose the activity to auto-renew group,

How to Set group expiration

First of all, we need an account that has at least one of the roles of following: Global administrator, Group administrator, or User administrator.

On the Azure AD Admin center, we select groups and expiration

We may configure the expiration page according to our policy or our needs,

There are 3 options, the Group lifetime in days. There are two three option there, 180, 365 and we can customize the days.

We should fill an email when a group has no owner, so, we specify an email address to which renewal and expiration notifications should be sent.

Choose which Microsoft 365 groups will expire. We can specify an expiration date for:

Every Microsoft 365 group

A selection of Microsoft 365 groups

None to limit the expiration date for all groups

When we are finished, we can select save to save our settings.

If groups are not automatically renewed, email notifications are sent to group owners in Microsoft 365 in 30 days, 15 days, and 1 day before the group expires. The preferred language of the group owner or the Azure AD language setting determines the language of the email. If the group owner has specified a preferred language, or if multiple owners have specified the same language, that language is used. The Azure AD language setting is used in all other cases. Group owners can directly access the group details page in the access panel from the Renew group notification email. There, users can find out more about the group, such as its description, when it was last renewed, when it will expire, and whether or not they can renew the group. The group details page now includes links to Microsoft 365 group resources, making it easier for the group owner to view the content and activity in their group. Group owners can directly access the group details page in the Access Panel from the Renew group notification email. There, users can find out more about the group, such as its description, when it was last renewed, when it will expire, and whether or not they can renew the group. The group details page now includes links to Microsoft 365 group resources, making it easier for the group owner to view the content and activity in their group. The deleted group can be restored within 30 days by selecting Restore group or by using PowerShell cmdlets:

the following cmdlet to display all deleted Microsoft 365 groups in your Azure AD organization that are still available to restore.

Get-AzureADMSDeletedGroup

Restore-AzureADMSDeletedDirectoryObject –Id <objectId>

How Microsoft 365 group expiration works with retention policy

The Security & Compliance Center is used to configure the retention policy. When a Microsoft 365 group expires and is deleted, the group conversations in the group mailbox and files in the group site are retained in the retention container for the number of days specified in the retention policy. Users will no longer be able to see the group or its content after it has expired, but they can recover the site and mailbox data through e-discovery.

More info:

https://learn.microsoft.com/en-us/microsoftteams/team-expiration-renewal

Set expiration for Microsoft 365 groups – Azure Active Directory – Microsoft Entra | Microsoft Learn

Leave a Reply

Your email address will not be published. Required fields are marked *