Dynamic Security Group Syntax - Exclude Disabled Users

Dean Hoile 61 Reputation points
2022-09-13T15:59:00.88+00:00

Hi,

I want to exclude all disabled users from a Dynamic Distribution Group but I am not sure of the syntax I would use.

This is the current syntax.

(user.country -eq "Gibraltar") or (user.country -eq "Hungary") or (user.country -eq "Isle of Man") or (user.country -eq "Malta")

I am trying to use

(user.country -eq "Gibraltar") or (user.country -eq "Hungary") or (user.country -eq "Isle of Man") or (user.country -eq "Malta") -and -not (user.accountEnabled -eq false) which is accepted but I am not seeing disabled users disappear from the list.

It's been around 30 minutes since I updated the Syntax in the rule, could I have it wrong?

Microsoft Security Microsoft Entra Microsoft Entra ID
0 comments No comments
{count} votes

Accepted answer
  1. Dillon Silzer 57,826 Reputation points Volunteer Moderator
    2022-09-13T16:13:08.023+00:00

    Hi @Dean Hoile

    You should correct this statement to:

    ((user.country -eq "Gibraltar") or (user.country -eq "Hungary") or (user.country -eq "Isle of Man") or (user.country -eq "Malta")) and (user.accountEnabled -eq false)

    Then try the Validate Rules (preview)

    240609-image.png

    -----------------------------------

    If this is helpful please accept answer.

    2 people found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. JamesTran-MSFT 36,906 Reputation points Microsoft Employee Moderator
    2022-09-13T18:21:05.98+00:00

    @Dean Hoile
    Thank you for your post!

    Adding onto what @Dillon Silzer mentioned, since you didn't see your Dynamic Security Group update after configuring the membership rules. You can definitely leverage the Validate a dynamic group membership rule (preview) feature to validate your dynamic rule, and confirm the rule is working as expected.

    Please keep in mind that depending on the size of your Azure AD organization, the group may take up to 24 hours for populating for the first time or after a rule change. For more info - Troubleshooting dynamic memberships for groups.

    (user.country -eq "Gibraltar") and (user.country -eq "Hungary") and (user.country -eq "Isle of Man") and (user.country -eq "Malta") and (user.accountEnabled -eq false)  
    

    240732-image.png

    I hope this helps!

    If you have any other questions, please let me know.
    Thank you for your time and patience throughout this issue.

    ----------

    Please remember to "Accept Answer" if any answer/reply helped, so that others in the community facing similar issues can easily find the solution.

    1 person found this answer helpful.

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.