We use cookies to improve your experience.
By your continued use of this site you accept such use.
For more details please see our privacy policy and cookies policy.

Script repository

Send mail to parent container owner

September 18, 2019 Views: 1312

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
Leave a comment
Loading...

Got questions?

Support Questions & Answers