Script Repository


Notify user of being added to a group

December 03, 2015
1173

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.

Parameters:

  • $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
PowerShell
$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
try
{
    $mail = $member.Get("mail")
}
catch
{
    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