Script Repository


Check if number of direct members exceeds limit

February 22, 2021
1440

The script returns True when the number of direct group members exceeds a certain limit. To run the script, create a business rule triggering Before adding a member to a group and add the script to the If PowerShell script returns true condition.

Parameter:

  • $maxMembers - Specifies the maximum number of members a group can have.
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 )
No results found.
Leave a comment

Related Scripts