Script Repository


Send mail to parent container owner

September 18, 2019
270

The script sends an email notification to the owner of the container where the target object is located.

Parameters:

  • $subject - Specifies the email notification subject.
  • $message - Specifies the email notification text.
Edit Remove
PowerShell
$subject = "My Subject" # TOOD: modify me
$message = @"
<Message Text>
"@ # TODO: modify me

# Bind to parent container
$parent = $Context.BindToObject($Context.TargetObject.Parent)

# Get the container manager
try
{
    $managerDN = $parent.Get("managedBy")
}
catch
{
    $Context.LogMessage("No manager is specified for container %adm-ParentName%", "Warning")
    return
}

# Get the manager email
$manager = $Context.BindToObjectByDN($managerDN)
try
{
    $managerMail = $manager.Get("mail")
}
catch
{
    $Context.LogMessage("No email address is specified for the manager of container %adm-ParentName%", "Warning")
    return
}

# Send mail
$Context.SendMail($managerMail, $subject, $message, $NULL)


Comments ( 0 )
No results found.
Leave a comment