Thank you for all the provided details. Here is the script you can use to send the email notification. It should be executed after the existing script in the business rule triggering After creating a user. In the script:
- $membersLimit - Specifies the maximum number of members the last non-full group should reach for the email to be sent.
- $groupDNs - Specifies distinguished names (DNs) of the groups taking part in the workflow. For information on how to get an object DN, see https://adaxes.com/sdk/HowDoI.GetDnOfObject. Must be the same as $groupDNs in the first script executed in the business rule triggering After creating a user.
- $to - Specifies the recipient of the email notification.
- $subject - Specifies the subject of the email notification. You can use value references in the subject. For example, to add the value of the user company property, use %company%.
- $body - Specifies the body of the email notification. You can use value references in the body. For example, to add the value of the user company property, use %company%.
$membersLimit = 3 # TODO: modify me
$groupDNs = @("CN=Group 1,OU=Groups,DC=domain,DC=com", "CN=Group 2,OU=Groups,DC=domain,DC=com") # TODO: modify me
# Mail settings
$to = "email@example.com" # TODO: modify me
$subject = " WARNING: ALL TS SECURITY GROUPS FOR %company% ARE ALMOST FULL." # TODO: modify me
$body = @"
The last TS security group for %company% is currently greater than 75 percent full.
"@ # TODO: modify me
# Add user to a group
$groupsReachedLimit = @()
foreach ($groupDN in $groupDNs)
# Bind to the group
$group = $Context.BindToObjectByDN($groupDN)
# Get group members
$groupMembers = $group.GetEx("adm-DirectMembersGuid")
# Check number of members
if ($groupMembers.Length -eq $membersLimit)
$groupsReachedLimit += $groupDN
# Send mail
if ($groupsReachedLimit.Length -eq 1)
$Context.SendMail($to, $subject, $body, $NULL)