Script repository
The script sends an email notification to members of an AD group. To execute the script, create a business rule, custom command or scheduled task configured for the Group object type.
Parameters
$subject- the email notification subject.$messageText- the email notification text.
$subject = "Notification to %name% members" # TODO: modify me
$messageText = @"
Attention to all %name% members!
This is a notification from your support team.
"@ # TODO: modify me
try
{
$memberGuidsInByte = $Context.TargetObject.GetEx("adm-MembersGuid")
}
catch
{
return
}
$toAddresses = @()
foreach($memberGuidInByte in $memberGuidsInByte)
{
$memberGuid = [guid]$memberGuidInByte
$groupMember = $Context.BindToObject("Adaxes://<GUID=$memberGuid>")
if($groupMember.Class -ieq "group")
{
continue
}
try
{
$mail = $groupMember.Get("mail")
}
catch
{
continue
}
$toAddresses += "$mail"
}
if ($toAddresses.Length -gt 0)
{
$toAddressesString = [System.String]::Join(",", $toAddresses)
$Context.SendMail($toAddressesString, $subject, $messageText, $NULL)
}
Comments 0
You must be signed in to comment.