Library

Guides Quick Fixes Scripts Find a Guide

Tools

Error Decoder Assessment Baselines Free Tools Service status What's Changed

More

AI Certifications For MSPs Recommended Gear Field Kit FAQ About Contact Get Assessment

Dynamic Membership Groups in Microsoft Entra ID

EntraReady Guides · Practical Microsoft 365 & Entra ID
Last reviewed:
Last verified against Microsoft Learn:

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

Step by step

  1. 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)).
  2. 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)).
  3. 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)).
  4. 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" (use Company, not Intune's Corporate)
    • 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))
  5. 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)).
  6. 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)).
  7. 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

Check it worked

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 Guides

Is this still accurate?

Spotted something outdated or wrong on this page? Tell us in a sentence. The page address is sent with it.

Reports go to the EntraReady inbox. Please don’t include passwords or tenant secrets.