Microsoft Graph PowerShell has officially replaced the older AzureAD module, making it necessary to update scripts and management routines accordingly. If you previously used Remove-AzureADMSLifecyclePolicyGroup to remove a Microsoft 365 group from a lifecycle policy, it’s time to transition to the Graph equivalent: Remove-MgGroupFromLifecyclePolicy.
In the AzureAD module, the Remove-AzureADMSLifecyclePolicyGroup cmdlet allowed you to disassociate a group from a specific lifecycle policy. This was helpful when a group no longer needed expiration management or policy-based governance.
Example:
Remove-AzureADMSLifecyclePolicyGroup -Id "11111111-1111-1111-1111-111111111111" -GroupId "ffffffff-ffff-ffff-ffff-ffffffffffff"
With Microsoft Graph PowerShell, you now use the Remove-MgGroupFromLifecyclePolicy cmdlet. It accepts parameters via a -BodyParameter hashtable and requires both the GroupLifecyclePolicyId and groupId in the body.
# Define the group lifecycle policy ID
$groupLifecyclePolicyId = "11111111-1111-1111-1111-111111111111"
# Define the parameters for the group removal
$params = @{
groupId = "ffffffff-ffff-ffff-ffff-ffffffffffff"
}
# Remove the group from the lifecycle policy
Remove-MgGroupFromLifecyclePolicy -GroupLifecyclePolicyId $groupLifecyclePolicyId -BodyParameter $params
This approach uses a clear and structured hashtable to pass in parameters — making the command more readable and compatible with bulk automation scenarios.
Feature | AzureAD Cmdlet | Microsoft Graph Cmdlet |
Cmdlet Name | Remove-AzureADMSLifecyclePolicyGroup | Remove-MgGroupFromLifecyclePolicy |
Parameter Format | Direct parameter values | Requires -BodyParameter hashtable |
Required Module | AzureAD | Microsoft.Graph.Groups |
Support and Future Updates | Deprecated | Actively supported |
Key difference: Graph requires parameters to be passed via -BodyParameter instead of using named arguments directly. This ensures consistency across Graph API-based calls.
Transitioning from Remove-AzureADMSLifecyclePolicyGroup to Remove-MgGroupFromLifecyclePolicy is a necessary step for maintaining up-to-date and supported scripts. With the Graph module, you're equipped with a more modern, flexible, and API-aligned approach to managing group lifecycle policies.
Whether you're managing a single group or automating lifecycle policy removal for multiple groups, adopting Remove-MgGroupFromLifecyclePolicy ensures better compatibility and future-proofing of your M365 scripts.
© Your Site Name. All Rights Reserved. Design by HTML Codex