As Microsoft phases out the AzureAD module, it’s time for administrators to migrate their scripts to the modern, secure, and flexible Microsoft Graph PowerShell SDK. One such commonly used cmdlet is New-AzureADMSGroupLifecyclePolicy, which was used to configure group expiration policies across Microsoft 365 groups.
In this article, you'll learn how to replace New-AzureADMSGroupLifecyclePolicy with New-MgGroupLifecyclePolicy, what’s different in the new Graph-based approach, and how to implement it with real-world examples.
Using the AzureAD module, you could create lifecycle policies that automatically expired Microsoft 365 groups after a certain number of days, with optional notification emails.
New-AzureADMSGroupLifecyclePolicy -GroupLifetimeInDays 180 `-AlternateNotificationEmails "samadmin@7xh7fj.onmicrosoft.com"
This created a lifecycle policy where groups expire after 180 days unless renewed, and email alerts were sent to the alternate contact.
The equivalent cmdlet in Microsoft Graph PowerShell SDK is New-MgGroupLifecyclePolicy. While the functionality remains the same, the implementation now uses a hashtable passed through the -BodyParameter parameter — a standard Graph pattern.
$params = @{
groupLifetimeInDays = 180
alternateNotificationEmails = "samadmin@7xh7fj.onmicrosoft.com"
}
New-MgGroupLifecyclePolicy -BodyParameter $params
In this example:
This syntax is more structured and consistent with the Graph API design principles.
🔄 Old (New-AzureADMSGroupLifecyclePolicy) | ➡️ New (New-MgGroupLifecyclePolicy) |
AzureAD module (deprecated) | Microsoft.Graph.Groups.LifecyclePolicies module |
Hardcoded input | Highly scriptable and extensible |
Less consistent with API model | Fully Graph-compliant design |
Limited integration with broader services | Works natively with other Graph modules |
Migrating from New-AzureADMSGroupLifecyclePolicy to New-MgGroupLifecyclePolicy is a simple yet important step toward future-proofing your Microsoft 365 group management strategy. With Microsoft Graph, you gain improved consistency, integration, and support for advanced automation scenarios.
Whether you're enforcing group expiration policies or ensuring continuity through alternate notification emails, New-MgGroupLifecyclePolicy is the reliable, modern tool to keep your directory clean and compliant.
© Your Site Name. All Rights Reserved. Design by HTML Codex