Script repository

Check if number of direct group members exceeds limit

Updated on: Jan 18, 2026, Views: 6134

Group membership

The script checks whether the number of direct group members exceeds the specified limit. If the limit is exceeded, the script returns true. The script should be executed in the If PowerShell script returns true condition in a business rule, custom command or scheduled task configured for the Group object type.

In the script, the $maxMembers variable specifies the number of direct members that should be exceeded for the condition to be met.

$maxMembers = 500 # TODO: modify me

# Get group member GUIDs
try
{
    $memberGuidsBytes = $Context.TargetObject.GetEx("adm-MembersGuid")
}
catch
{
    # The group has no members
    $Context.ConditionIsMet = $False
    return
}

$Context.ConditionIsMet = $memberGuidsBytes.Length -ge $maxMembers

Comments 0

You must be signed in to comment.

    Got questions?

    Support Questions & Answers

    We use cookies to improve your experience.
    By your continued use of this site you accept such use.
    For more details please see our privacy policy and cookies policy.