Script repository
The script sends an email notification to everybody who has Full Access to the target mailbox. To execute the script, create a business rule, custom command or scheduled task configured for the User object type.
Parameters
$subject- the email notification subject.$message- the email notification text.
# Email settings
$subject = "My Subject" # TODO: modify me
$message = "My Message" # TODO: modify me
# Get Exchange properties.
$mailboxParams = $Context.TargetObject.GetMailParameters()
# Get Full Access permissions.
$objectReferences = $mailboxParams.MailboxRights.GetTrusteesGrantedRights("ADM_EXCHANGE_MAILBOX_RIGHTS_FULL_ACCESS")
foreach ($objectReference in $objectReferences)
{
$sid = $objectReference.ObjectSid
if ([System.String]::IsNullOrEmpty($sid))
{
continue
}
elseif ([Softerra.Adaxes.Utils.WellKnownSecurityPrincipalInfo]::IsWellKnown($sid))
{
continue
}
try
{
# Get object email.
$object = $Context.BindToObject("Adaxes://<SID=$sid>")
$to = $object.Get("mail")
}
catch
{
continue
}
# Send mail
$Context.SendMail($to, $subject, $message, $NULL)
}
Comments 0
You must be signed in to comment.