Dynamic Membership Groups in Microsoft Entra ID
Dynamic membership groups add and remove users or devices automatically based on their attributes, so a "Sales users" or "Corporate iPhones" group stays accurate without anyone touching it. When a user's or device's attributes change, Microsoft Entra ID evaluates the dynamic rules in the tenant and adds or removes members to match; you can't add or remove members by hand (Considerations (opens in a new tab)). This guide covers writing a rule, testing it before anyone loses access, and what to check when a group stops updating.
Use it when: you target licensing, Conditional Access, app assignments or Autopilot profiles at a population defined by attributes (department, company, device ownership, Autopilot order ID). For Intune app and policy assignments, Microsoft recommends assignment filters where they meet the need, and dynamic groups for non-Intune or cross-workload cases such as Conditional Access, licensing or Autopilot profile assignment (Rules for devices (opens in a new tab)).
Before you start
- License: Microsoft Entra ID P1 (or Intune for Education) for each unique user who is a member of one or more dynamic groups. You don't have to assign the license to those users, but you need enough licenses in the tenant to cover them. Device members need no license (License requirements (opens in a new tab)).
- Role: at least Groups Administrator to create, edit, validate, pause or convert dynamic groups (Create a rule (opens in a new tab), Validate rules (opens in a new tab)). Assigning the role through an indirect role assignment isn't supported for rule validation.
- Limits: a tenant can have up to 15,000 dynamic membership groups (Overview (opens in a new tab)); a rule body can't exceed 3,072 characters (Rule syntax (opens in a new tab)).
- Clean up first: rules evaluate every user and device, including inactive ones, so stale objects inflate membership and slow processing. Microsoft recommends cleaning up stale devices and inactive users before you create a rule (Create or edit a dynamic group (opens in a new tab)). See Clean up stale devices and Inactive user cleanup.
Step by step
- Decide users or devices. One group holds users or devices, never both, and a device rule can reference only device attributes, not the owner's user attributes. Security groups can hold users or devices; Microsoft 365 groups hold only users (Considerations (opens in a new tab)).
- Check who can write the attributes you use. The group is only as secure as the attribute: if users can edit their own value (for example a synced on-premises attribute with SELF write), they can put themselves into a group that grants access. Audit write permissions in Microsoft Entra ID and the source directory before using an attribute in a group that controls access (Security consideration (opens in a new tab)).
- Create the group. In the Microsoft Entra admin center go to Entra ID > Groups > All groups > New group, enter a name, choose a Membership type for users or devices, and select Add dynamic query (Create a rule (opens in a new tab)).
- Write the rule. The rule builder handles up to five expressions and only user rules; device rules, direct reports,
-contains/-notContains, operator precedence and complex expressions need the text box (Rule builder (opens in a new tab)). Examples from Learn:- Single attribute:
user.department -eq "Sales" - All member users, no guests:
(user.objectId -ne null) -and (user.userType -eq "Member")(All users (opens in a new tab)) - Extension attribute:
(user.extensionAttribute15 -eq "Marketing")(Extension attributes (opens in a new tab)) - Company-owned devices:
device.deviceOwnership -eq "Company"(useCompany, not Intune'sCorporate) - All Autopilot devices:
device.devicePhysicalIDs -any _ -startsWith "[ZTDId]" - Intune-managed devices:
device.deviceManagementAppId -eq "0000000a-0000-0000-c000-000000000000"(Device attributes (opens in a new tab))
- Single attribute:
- Validate before you save. On the group's Dynamic membership rules page, open Validate Rules, pick up to 20 users or devices you know should and shouldn't match, and use View details to see which expression passed or failed (Validate rules (opens in a new tab)).
- Converting an existing static group? Test first. You can switch Properties > Membership type to Dynamic User or Dynamic Device and keep the same group name and ID. Members who don't match the rule are removed, and if the group grants access, original members can lose it until processing completes (Change static groups to dynamic (opens in a new tab)).
- Watch processing. The group's Overview shows Dynamic rule processing status (Evaluating, Processing, Update complete, Processing error, Update paused, Not started) and Last membership change (Check the processing status (opens in a new tab)). First population or a rule change can take up to 24 hours in a large tenant (Troubleshoot (opens in a new tab)).
Report-first PowerShell
Read-only inventory of dynamic groups and their rules (Microsoft Graph PowerShell). Scope: Group.Read.All (listed for List groups; Learn shows Group-NestingSupport.ReadWrite.All as the least-privileged entry, but that is a write scope, so stay with a read scope) (List groups permissions (opens in a new tab)).
Connect-MgGraph -Scopes "Group.Read.All"
# groupTypes filter and ConsistencyLevel usage per the List groups example for dynamic groups
Get-MgGroup -Filter "groupTypes/any(s:s eq 'DynamicMembership')" -All `
-Property "id,displayName,membershipRule,membershipRuleProcessingState" `
-ConsistencyLevel eventual -CountVariable c |
Select-Object DisplayName, MembershipRuleProcessingState, MembershipRule |
Export-Csv .\dynamic-groups.csv -NoTypeInformation
The List groups doc shows filtering dynamic groups by groupTypes/any(s:s eq 'DynamicMembership') or membershipRuleProcessingState with ConsistencyLevel: eventual (List groups, dynamic groups example (opens in a new tab)). Look for groups in Paused state that someone forgot to resume.
For a Windows device rule, confirm the OS version format first: Get-MgDevice -Search "displayName:PC-NAME" -ConsistencyLevel eventual | Select-Object -ExpandProperty OperatingSystemVersion (scope Device.Read.All, per List devices (opens in a new tab)). Learn's Windows 10 example is device.deviceOSVersion -startsWith "10.0.1" (Rules for devices (opens in a new tab)).
Gotchas
- Old
memberOfpreview groups have stopped updating. The earliermemberOfpreview ended on November 3, 2026; groups still using it froze in their last known state. Its replacement, MemberOf Next (preview), needs Microsoft Entra ID Governance and the group's priority set to Standard. Standard priority groups update on a twice-daily schedule (Deprecated memberOf preview (opens in a new tab), MemberOf Next (opens in a new tab)). Don't rely on a Standard priority group to revoke access immediately. - Processing error freezes membership. While a group shows Processing error, members from the last successful run stay and nobody new is added, so policies targeted at the group miss new users (Processing status (opens in a new tab)).
- Paused groups hide bad rules. A rule that references an unsupported property can be saved while processing is paused, and the error only appears when you resume (Update an existing rule (opens in a new tab)).
- Null checks: use
-eq null/-ne nullwithout quotes, and never-notwith null (Use of null values (opens in a new tab)). - Role-assignable groups can't be dynamic; they require assigned membership (Security consideration (opens in a new tab)).
- Welcome emails: users added to a dynamic Microsoft 365 group get the welcome email; turn it off with
Set-UnifiedGroupin Exchange PowerShell (Welcome email (opens in a new tab)). - Don't use
organizationalUnitin device rules; Microsoft Entra ID doesn't recognize it and no devices are added (Rules for devices (opens in a new tab)). - No on-demand refresh. There's no button to force processing; Learn's workaround is to edit the rule and add a trailing space (Troubleshoot (opens in a new tab)).
Check it worked
- Group Overview shows Update complete and a recent Last membership change.
- Validate Rules results match your known test users or devices.
- The exported CSV shows no unexpected
Pausedgroups, and member counts are in the range you expected.
Roll back
Pause processing from the group's Overview page (Groups Administrator) to freeze membership while you fix a rule (Processing status (opens in a new tab)), or switch Membership type back to Assigned under Properties; the group keeps its name and ID (Change static groups to dynamic (opens in a new tab)).
Related on EntraReady: Inactive user cleanup, Clean up stale devices, Troubleshoot Windows Autopilot enrollment, Conditional Access baseline.
← All GuidesIs this still accurate?
Spotted something outdated or wrong on this page? Tell us in a sentence. The page address is sent with it.