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.

Script repository

Check if number of direct members exceeds limit

May 13, 2021 Views: 2495

The script returns True when the number of direct group members exceeds a certain limit. Run the script in the If PowerShell script returns true condition of a business rule, custom command or scheduled task configured for the Group object type.

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

Edit Remove
PowerShell
$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 # Exit script
}

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

Comments 0
Leave a comment
Loading...

Got questions?

Support Questions & Answers