Skip to main content
Graduate Track

Creating a Dynamic Membership Group in Microsoft Entra ID and Validating Its Rule

Create a dynamic user group in Microsoft Entra ID, test its rule on the Validate Rules tab before it controls access, and read processing status safely.

Creating a Dynamic Membership Group in Microsoft Entra ID and Validating Its Rule
KBY Technologies13 min readFoundation12 min

In this lesson

Advertising disclosure: this article includes partner links. KBY may earn a commission if you sign up or buy through one, at no extra cost to you. How we make money.

Share

Before you begin

  • A test tenant or a permitted lab where nothing depends on the lab group.
  • Enough Microsoft Entra ID P1 or Intune for Education licences for each unique dynamic-group member.
  • At least Groups Administrator for the group and User Administrator for the test users.

Track this tutorial

Choose your current status and tick each safety check as you complete it. Sign in to sync progress between devices.

Current status

Before you apply the change

Confirm these production-safety controls during the tutorial.

0 of 6 safety checks completed

To create a dynamic membership group in Microsoft Entra ID, sign in to the Microsoft Entra admin center as at least a Groups Administrator, browse to Entra ID > Groups > All groups, select New group, choose a Membership type for users or devices and select Add dynamic query to write the rule. Before the group controls anything, open its Dynamic membership rules page and use the Validate Rules tab to test the rule against up to 20 chosen users or devices at a time. Dynamic membership groups need a Microsoft Entra ID P1 licence (or an Intune for Education licence) for each unique user who is a member of one or more of them, so check that your lab tenant is covered first.

The reason to learn this carefully is that a dynamic group is not a list someone maintains: it is the result of a rule applied to user or device attributes, recalculated whenever those attributes change. That makes it powerful for onboarding and leaving, and risky when the rule or the data is wrong, because the group can grow or shrink with nobody clicking anything. This guide builds a small lab group from first principles, proves the rule selects exactly the accounts you intend before the group controls anything, and shows how to read processing status and pause processing if membership goes wrong.

#Learning Objectives

  • Explain how a dynamic membership rule turns user attributes into group membership, and why that makes attribute ownership a security question.
  • Write a single-expression user rule with the correct <Property> <Operator> <Value> syntax.
  • Create a dynamic user security group with the least privileged role that Microsoft documents for the task.
  • Validate a rule against sample users on the Validate Rules tab and read the per-expression details.
  • Read the Dynamic rule processing status, and pause processing as a stop control.

#Prerequisites

  • A test or developer tenant, or a tenant where your change process allows a lab group that nothing depends on. Do not use a group that is already assigned to apps, licences or Conditional Access policies.
  • Enough Microsoft Entra ID P1 (or Intune for Education) licences in the tenant to cover each unique user who will be a member of a dynamic group. Licences do not have to be assigned to the users themselves.
  • At least the Groups Administrator role to create the group, validate the rule and pause processing; at least the User Administrator role to create the two test users and edit their Department. Microsoft notes that assigning the role needed to validate rules through an indirect role assignment is not supported.
  • Optional: the Microsoft Graph PowerShell SDK, if you want to read membership from the command line.

#Content

#
Assigned membership and dynamic membership

A group in Entra ID is a set of identities you can grant access to once instead of one person at a time. With Assigned membership, an administrator adds and removes members by hand. With dynamic membership, a rule decides. Microsoft describes what happens next: when an attribute of a user or device changes, the service evaluates all dynamic membership rules in the directory; objects that satisfy a group’s rule are added and objects that no longer satisfy it are removed. You cannot manually add or remove a member of a dynamic membership group, so the rule is the only lever you have.

That is the first-principles model worth carrying into every Entra ID task: membership is not a list you maintain, it is the output of a function applied to attribute data. If the output is wrong, the fault is in the rule, in the data, or in processing. You will check each of those in turn.

#
What a rule looks like

A single expression takes the form <Property> <Operator> <Value>, with the property written as object.property. Microsoft’s own example is user.department -eq "Sales". A few syntax rules from the documentation matter immediately:

  • Property names are case sensitive, so write them exactly as documented (for example user.department).
  • String comparisons and regular expressions are not case sensitive, so "Sales" and "sales" match the same users.
  • String values go in double quotation marks; for a null check use -eq null or -ne null without quotes, and never -not as the comparison.
  • Expressions can be combined with -and, -or and -not; use parentheses when the default precedence (comparison operators, then -not, then -and, then -or) is not what you mean.
  • The body of a rule cannot exceed 3,072 characters.

#
Rule builder or text box

The portal’s rule builder constructs up to five expressions and is available only for user-based groups. Device-based rules, rules with more than five expressions, direct-report rules, rules that set operator precedence and rules that use -contains or -notContains need the text box. The builder does not change how a rule is validated or processed; it is only an editor.

#
Trust boundaries: who can change the attribute?

Microsoft’s security guidance for dynamic groups is that a group’s membership is only as trustworthy as the write permissions on the attributes its rule uses. If someone can edit department, they can move a user into or out of the group. This matters most for attributes synchronised from on-premises Active Directory, where some attributes can be configured so users can write their own values, and for groups that control access to sensitive apps or Conditional Access policies. Microsoft also notes that role-assignable groups require assigned membership, which removes this risk for groups that grant admin roles. Before you pick an attribute in production, find out who can write it, both in Entra ID and at the source directory.

A diverse group of professionals collaborating with sticky notes in a modern office environment.
Photo by Alena Darmel on Pexels

#
Processing status

The group’s Overview page shows Dynamic rule processing status and Last membership change. The documented statuses are Evaluating, Processing, Update complete, Processing error, Update paused and Not started. While the status is Processing error, membership is frozen: members from the last successful evaluation stay, and no new members are added. Microsoft does not publish a fixed processing time on these pages, so treat the status, not a stopwatch, as your evidence.

#Examples

#
Worked example: a finance group that maintains itself

A small organisation wants every user whose Department is Finance in one security group, so the group can later be used to target a finance app. The rule is a single expression:

1user.department -eq "Finance"

Before the group is used for anything, the administrator opens Validate Rules, selects three known finance users and two users from other departments, and confirms the first three show as members and the other two do not. Only then is the group assigned to the app. This order, validate before assigning, is the habit the exercise below trains.

#
Worked example: one rule for several values

If Finance and Payroll should share the group, it is tempting to chain -or clauses. Microsoft’s guidance on efficient rules recommends the -in operator instead, because a single criterion is easier to evaluate:

1user.department -in ["Finance", "Payroll"]

The same guidance recommends preferring -eq, then -startsWith or -endsWith, over -match and -contains, which increase processing time, especially in tenants with many dynamic groups.

#Exercises

#
Exercise: build a lab dynamic group and prove its rule before it controls anything

Objective: create a dynamic user security group whose rule selects exactly one of two test users, prove it on the Validate Rules tab, watch membership change when an attribute changes, and practise pausing processing.

Safe setup and backup: work in a test tenant, or in a tenant where the lab is permitted. Use department values that no real user has, such as KBY-Lab-Finance and KBY-Lab-Sales, so the rule cannot pick up real people. Create the test users with Account enabled cleared, so they cannot sign in. Write down the two test users’ user principal names, their starting department values and the lab group’s name and object ID; this record is your backup, because it is everything you need to return the lab to its starting state.

  1. Create two test users: sign in as at least a User Administrator, browse to Entra ID > Users and select New user > Create new user. On Basics, clear Account enabled. On Properties, under Job information, set Department to KBY-Lab-Finance for Lab Dyn One and KBY-Lab-Sales for Lab Dyn Two, then select Review + create. Expected result: both users appear under All users.
  2. Create the group: as at least a Groups Administrator, browse to Entra ID > Groups > All groups and select New group. Choose the Security group type, name it LAB-DYN-Finance, set Membership type to Dynamic User and select Add dynamic query. In the text box, enter user.department -eq "KBY-Lab-Finance", select Save, then select Create. Expected result: the group is created; if the rule were invalid, the portal would explain why it could not be processed.
  3. Validate the rule: open LAB-DYN-Finance, select Dynamic membership rules and open the Validate Rules tab. Select both lab users, then choose Select. Expected result: validation starts automatically; Lab Dyn One shows as a member and Lab Dyn Two does not. Select View details on Lab Dyn Two: the expression result shows the department comparison evaluating to false.
  4. Check processing: open the group’s Overview. Expected result: Dynamic rule processing status moves through Evaluating or Processing to Update complete, and Last membership change shows a date and time. The group’s Members list then shows Lab Dyn One only.
  5. Change an attribute: as a User Administrator, open Lab Dyn Two, select Edit properties, open Job information, change Department to kby-lab-finance (lower case on purpose) and select Save. Expected result: after processing reaches Update complete, Lab Dyn Two is also a member, because string comparisons are not case sensitive.
  6. Practise the stop control: on the group’s Overview, select Pause processing. Expected result: the status shows Update paused. Then resume processing so the group reflects the rule again.

Pass condition: the Validate Rules results matched your prediction before any membership change was visible, the Members list matched the rule after Update complete, and the attribute change in step 5 moved Lab Dyn Two into the group without you adding it.

Stop conditions: stop if validation shows Unknown (select View details and fix the rule first), if the status shows Processing error, if any user other than the two lab users appears in Members, or if the group you opened is not LAB-DYN-Finance. If unexpected members appear, select Pause processing and correct the rule before resuming.

Cleanup and rollback: set Lab Dyn Two‘s Department back to KBY-Lab-Sales; after processing, it leaves the group. To finish, delete the lab group and, as a User Administrator, the two lab users; a deleted user stays on Deleted users for 30 days and can be restored during that time. Microsoft documents that a deleted cloud security group is retained for 30 days and can be restored from Groups > All groups > Deleted groups (soft delete for cloud security groups is in preview), so a mistaken group deletion inside that window is recoverable. Never select Delete permanently on that page.

#Validation Guidance

Validation for a dynamic group answers three separate questions, and each needs its own evidence:

  1. Is the rule logically right? Use Validate Rules with users you expect to be in and users you expect to be out. You can select 20 users or devices at a time. A result of Unknown means the rule is not valid or there was a network problem; View details gives the error and the fix.
  2. Is the data right? When a user is wrongly out, View details shows which expression failed. Compare that with the user’s actual property value on their profile. Usually the rule is fine and the attribute is empty or spelled differently.
  3. Has processing finished? Only trust the Members list after Dynamic rule processing status shows Update complete. If no pending dynamic group updates can be processed for any group in the organisation for more than 24 hours, Microsoft shows an alert above All groups; escalate to whoever owns the tenant if you see it.

For a command-line record, Microsoft Graph PowerShell can list the members. Connect-MgGraph -Scopes 'GroupMember.Read.All' followed by Get-MgGroupMember -GroupId '<lab-group-object-id>' -All returns the current members, and (Get-MgGroup -GroupId '<lab-group-object-id>').GroupTypes includes DynamicMembership for a dynamic group. Both are read-only. The documented Graph equivalent of the portal’s stop control is Update-MgGroup -GroupId '<lab-group-object-id>' -MembershipRuleProcessingState "Paused", reversed with "On"; it changes state, so run it only against the lab group.

#Common Mistakes

A clipboard with the phrase 'Office Rules' spelled out using Scrabble tiles on a beige background.
Photo by DS stories on Pexels

#
Trying to add a member by hand

Dynamic groups do not accept manual additions or removals. If one person needs an exception, change the rule or the attribute, or use a separate assigned group.

#
Converting a live group without testing

Changing an existing assigned group to dynamic keeps the same name and object ID, but members who do not meet the new rule are removed. If the group controls access, those people can lose access until processing completes. Microsoft advises testing the rule beforehand; the Validate Rules tab is how you do that.

#
Writing property names in the wrong case

Values are case insensitive but property names are case sensitive. user.department is correct; copy property names from Microsoft’s supported properties list rather than typing them from memory.

#
Reaching for -match and -contains

They work, but they cost processing time across the tenant. Use -eq when you know the whole value, and -startsWith or -endsWith for a prefix or suffix.

#
Mixing users and devices

A rule cannot contain both users and devices, and a device rule cannot use the device owner’s user attributes. Microsoft 365 groups can contain only users.

#
Ignoring Processing error

A group in Processing error looks normal in its member list but has stopped updating. New starters who should be covered are not. When processing is on, a rule that references an unsupported property cannot be saved; if processing was paused, it saves and the error appears only after you resume.

#Key Takeaways

  • A dynamic group’s membership is the output of a rule over attribute data; you cannot add or remove members by hand.
  • Groups Administrator is the least privileged role Microsoft documents for creating, validating and pausing dynamic groups.
  • Validate with users you expect in and users you expect out before the group is assigned to anything.
  • Trust the member list only after Update complete, and treat Processing error as frozen membership.
  • Choose attributes whose write access you control; the group is only as secure as those attributes.

#Before You Use a Dynamic Group in Production

Use the same sequence on real groups: confirm licensing, confirm who can write the attribute, write the simplest rule that works, validate against a representative sample of in and out users, and only then assign the group to an app, licence or policy. Keep Pause processing as your stop control if membership starts changing in ways you did not predict, and remember that a tenant can hold at most 15,000 dynamic membership groups. When a sign-in fails for a member of an app-assigned group, KBY’s guide to AADSTS50105: User Not Assigned to Enterprise Application is the next place to look. For admin roles, use assigned, role-assignable groups and time-limited activation through Privileged Identity Management instead, as in Configuring Entra ID PIM for Just-in-Time Admin Access.

Evidence trail

Sources and verification

Primary documentation and external technical references used in this article.

  1. 01Create or update a dynamic membership grouplearn.microsoft.com
  2. 02Validate rules for dynamic membership groupslearn.microsoft.com
  3. 03Manage rules for dynamic membership groupslearn.microsoft.com
  4. 04Create simpler, more efficient ruleslearn.microsoft.com
  5. 05Change static group membership to dynamiclearn.microsoft.com
  6. 06Restore a deleted grouplearn.microsoft.com

About this page

Credited to

Dates

Published

Corrections

No corrections are listed for this page. Some review sweeps corrected pages without naming each one; those are in the corrections log.

Reader Interaction

Comments

Add a thoughtful note on Creating a Dynamic Membership Group in Microsoft Entra ID and Validating Its Rule. Comments are checked for spam and held for moderation before appearing.

Loading comments...

Discover more

Was this useful?

Reports go to the site owner and are used to correct pages. Corrections are listed at /corrections.

Build practical engineering skills.

Receive new lessons, learning paths, practical exercises and early-career guidance.