Script Repository

Notify user being added to a group

May 04, 2020

This script sends an email notification to a user when they are added to an AD group. To use it with Adaxes, you need to create a Business Rule triggered After adding a member to a group that runs the script using the Run a program or PowerShell script action.


  • $subject - Specifies the subject of the notification.
  • $bodyText - Specifies the notification text. In the text, {0} is a placeholder where the new member's full name will be inserted.
Edit Remove
$subject = "You have been added to Group %name%" # TODO: modify me
$bodyText = @"
Dear {0},

You have been added to group %name%.

Please do not reply to this e-mail, it has been sent to you for notification purposes only.
"@ # TODO: modify me

# Bind to the new member
$member = $Context.BindToObject("Adaxes://%member%")

# Get email address of the new member
    $mail = $member.Get("mail")
    return # No email address specified

# Insert the new member name in the e-mail body
$userFullName = $member.Get("name")
$body = [System.String]::Format($bodyText, $userFullName)

$Context.SendMail($mail, $subject, $body, $NULL)

Comments ( 0 )
No results found.
Leave a comment