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 notification to everybody who has Full Access to mailbox

October 29, 2019 Views: 934

The script sends an email notification to everybody who has Full Access to the target mailbox.

Parameters:

  • $subject - Specifies the email notification subject.
  • $message - specifies the email notification text.
Edit Remove
PowerShell
# E-mail 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
    }
    
    # Get object email
    try
    {
        # Bind to object
        $object = $Context.BindToObject("Adaxes://<SID=$sid>")
        $to = $object.Get("mail")
    }
    catch
    {
        continue
    }
    
    # Send mail
    $Context.SendMail($to, $subject, $message, $NULL)
}
Comments 0
Leave a comment
Loading...

Got questions?

Support Questions & Answers