Script repository

Grants mailbox permissions to accounts specified in a custom command parameter

Updated on: Jan 18, 2026, Views: 1740

Exchange

The scripts grant permissions to the accounts specified in a custom command parameter of the target account mailbox. To execute the script, create a custom command configured for the required object type.

Script 1: Grant Send on Behalf permission

The script grants the Send on Behalf permission to the accounts specified in a custom command parameter of the target account mailbox.

Parameters

  • $paramName - the name of the Directory object picker parameter used to select the accounts that will gain the Send on Behalf Of permission. The name must start with the param- prefix.
  • $separator - the value (e.g. semicolon) specified in the parameter settings to separate multiple values. The separator should not be a comma as it is used in distinguished names (DNs).
$paramName = "param-MyParam" # TODO: modify me
$separator = ";" # TODO: modify me 

# Create an instance of the 'AdmExchangeMailboxParameters' class.
$mailboxParams = New-Object "Softerra.Adaxes.Adsi.Exchange.AdmExchangeMailboxParameters"
$sendOnBehalfOf = $mailboxParams.GrantSendOnBehalfTo
$sendOnBehalfOf.OverrideOldValues = $False

# Get delegates DNs.
$delegatesDNs = $Context.GetParameterValue($paramName).Split($separator)

foreach ($delegateDN in $delegatesDNs)
{
    # Create object reference.
    $objReference = New-Object "Softerra.Adaxes.Adsi.AdmObjectReference"
    $objReference.ObjectDN = $delegateDN
    
    # Add delegate to 'Send On Behalf Of'.
    $sendOnBehalfOf.Add("ADS_PROPERTY_APPEND", $objReference)
}

# Save changes
$mailboxParams.GrantSendOnBehalfTo = $sendOnBehalfOf
$Context.TargetObject.SetMailParameters($mailboxParams, "ADM_SET_EXCHANGE_PARAMS_FLAGS_NONE")

Script 2: Grant Full Access permission

The script grants the Full Access permission to the accounts specified in a custom command parameter of the target account mailbox.

Parameters

  • $paramName - the name of the Directory object picker parameter used to select the accounts that will gain the Full Access permission. The name must start with the param- prefix.
  • $separator - the value (e.g. semicolon) specified in the parameter settings to separate multiple values. The separator should not be a comma as it is used in distinguished names (DNs).
$paramName = "param-myParam" # TODO: modify me
$separator = ";" # TODO: modify me

# Create an instance of the AdmExchangeMailboxParameters class
$mailboxParams = New-Object "Softerra.Adaxes.Adsi.Exchange.AdmExchangeMailboxParameters"
$sendOnBehalfOf = $mailboxParams.GrantSendOnBehalfTo
$sendOnBehalfOf.OverrideOldValues = $False

# Get delegates DNs
$delegatesDNs = $Context.GetParameterValue($paramName).Split($separator)

$mailboxRights = $mailboxParams.MailboxRights

foreach ($delegateDN in $delegatesDNs)
{
    # Create object reference
    $objReference = New-Object "Softerra.Adaxes.Adsi.AdmObjectReference"
    $objReference.ObjectDN = $delegateDN
    
    # Create permission
    $permission = New-Object "Softerra.Adaxes.Adsi.Exchange.AdmExchangeMailboxPermission"
    $permission.AllowedRights = "ADM_EXCHANGE_MAILBOX_RIGHTS_FULL_ACCESS"
    $permission.Trustee = $objReference
    
    # Add permission modification
    $permissionModification = New-Object "Softerra.Adaxes.Adsi.Exchange.AdmExchangeMailboxRightsModification"
    $permissionModification.Operation = "ADS_PROPERTY_APPEND"
    $permissionModification.Permission = $permission
    
    $mailboxRights.AddModification($permissionModification)
}

# Save changes
$mailboxParams.MailboxRights = $mailboxRights
$Context.TargetObject.SetMailParameters($mailboxParams, "ADM_SET_EXCHANGE_PARAMS_FLAGS_NONE")

Comments 0

You must be signed in to comment.

    Got questions?

    Support Questions & Answers

    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.