Microsoft Entra ID group life cycle policies are crucial for automating group expiration, renewal, and cleanup, helping organizations maintain an organized and secure directory. IT administrators often need to create these policies to enforce governance and prevent inactive groups from cluttering the system. While the New-MgGroupLifecyclePolicy PowerShell command in Microsoft Graph allows admins to create life cycle policies, it requires complicated scripts and manual efforts.
Before running the New-MgGroupLifecyclePolicy cmdlet, ensure the following requirements are met:
Install-Module Microsoft.Graph -Scope CurrentUser
Connect-MgGraph -Scopes "Group.Read.All"
Use the New-MgGroupLifecyclePolicy cmdlet in Microsoft Graph PowerShell to create new life cycle policies for Microsoft Entra ID groups. The syntax is as follows:
New-MgGroupLifecyclePolicy
[-ResponseHeadersVariable <String>]
[-AdditionalProperties <Hashtable>]
[-AlternateNotificationEmails <String>]
[-GroupLifetimeInDays <Int32>]
[- Id <String>]
[-ManagedGroupTypes <String>]
[-Headers <IDictionary>]
[-ProgressAction <ActionPreference>]
[-WhatIf]
[-Confirm]
;CommonParameters>]
Example: Create a life cycle policy for a Microsoft Entra ID group
$params = @{
groupLifetimeInDays = 100
managedGroupTypes = "Selected"
alternateNotificationEmails = "admin@contoso.com"
}
New-MgGroupLifecyclePolicy -BodyParameter $params
The table below lists key parameters that can be used with the New-MgGroupLifecyclePolicy cmdlet to create Microsoft Entra ID group life cycle policies.
| Parameters | Description |
|---|---|
| -AdditionalProperties | This specifies the additional parameters. |
| -AlternateNotificationEmails | This lists the email addresses for notifying groups without owners. |
| -GroupId | This is the unique identifier of the group. |
| -GroupLifetimeInDays | This shows the number of days before a group expires and needs to be renewed. |
| -Confirm | This prompts you to confirm before running the cmdlet. |