0 votes

So this works for us however we would like to add to check if the last group is at 3 users we would like to send a seperate email but would still like all the above to continue to happen the way it is.

related to an answer for: Can you load balance security groups?
by (180 points)
0

Hello,

Sorry for the confusion, but we are not sure what exactly you mean. Do you need to send an email notification when the third member is added to a specific group? If that is not it, please, describe the desired behaviour in all the possible details with live examples.

0

In my last question a script was created to send a email when all groups are full I want a seperate email sent if the last group is more than 75% full

0

Hello,

Thank you for clarifying. Could you, please, also specify what needs to be included into the email? A live example of the notification will be much appreciated.

0

Subject = WARNING: ALL TS SECURITY GROUPS FOR %company% ARE ALMOST FULL. Body = The last TS security group for %company% is currently greater than 75 percent full.

0

Hello,

Do we understand correctly that %company% stands for the value of the company property of the user being created?

0

Yes

1 Answer

0 votes
by (292k points)

Hello,

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 = "recipient@domain.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
 try
 {
     $groupMembers = $group.GetEx("adm-DirectMembersGuid")
 }
 catch
 {
     return
 }

 # Check number of members
 if ($groupMembers.Length -eq $membersLimit)
 {
    $groupsReachedLimit += $groupDN
 }    
}

# Send mail
if ($groupsReachedLimit.Length -eq 1)
{
    $Context.SendMail($to, $subject, $body, $NULL)
}

Related questions

0 votes
1 answer

We have a 3rd party vendor that we are able to add users based on AD security groups. What I need to do is set a parameter for the number of available licenses and whenever ... the group is 495 I would like an email to trigger telling me to add more licenses.

asked Oct 12, 2022 by A_Pastor (70 points)
0 votes
1 answer

Is there any way to add a warning message when someone tries to add a group member that already is member? Checked config but found nothing related. Added a new member that ... the group and there is no warning, and the logs show that the task was completed.

asked Jul 9 by lramirez (20 points)
0 votes
1 answer

Greetings. When I create the parameters to make a business rule that looks for users whose Email Proxy Adresses does not contain 'SMTP:%userPrincipalName%', it still generates profiles ... and primary SMTP address don't match. Version is 2023 How rule is set

asked Dec 19, 2022 by MShep (80 points)
0 votes
1 answer

For creating a computer object, we want to check if the entered CN is already used in our AD. And for that we want to use a powershell script. An other dot ... powershell script should be start before creating the computer object, right? Thanks for your help.

asked Jun 4 by KEME (80 points)
0 votes
1 answer

Hi, we currenlty have a business rule to send an email everytime the Title, Manager, Department, accountExpires, EmployeeType or FirstName attributes are ... Unit: %BusinessUnit% End Date: %accountExpires% Effective Date of Change: %adm-CustomAttributeDate2%

asked Feb 14 by KevC (60 points)
3,569 questions
3,259 answers
8,275 comments
547,985 users