Script repository

Update linked mailbox properties with values of the master account

Updated on: Jan 18, 2026, Views: 2331

Exchange

The script updates properties of a linked mailbox with the corresponding property values of the master account. The script should be executed by a custom command, business rule or scheduled task on the master account. If a property is empty in the master account, it will also be cleared for the linked mailbox.

In the script, the $propertiesToCopy variable specifies the names of the properties to be updated.

$propertiesToCopy = @("givenName", "sn", "displayName") # TODO: modify me

# Get Exchange properties.
$mailboxParams = $Context.TargetObject.GetMailParameters()

# Build linked mailbox ADS path.
$linkedMailboxIdentity = $mailboxParams.LinkedMailbox
if ($linkedMailboxIdentity.ObjectDN)
{
    $linkedMailboxPath = "Adaxes://" + $linkedMailboxIdentity.ObjectDN
}
elseif ($linkedMailboxIdentity.ObjectGuid)
{
    $linkedMailboxPath = "Adaxes://<GUID=" + $linkedMailboxIdentity.ObjectGuid + ">"
}
elseif ($linkedMailboxIdentity.ObjectSid)
{
    $linkedMailboxPath = "Adaxes://<SID=" + $linkedMailboxIdentity.ObjectSid + ">"
}
else
{
    $Context.LogMessage("Unable to get object path: " + $linkedMailboxIdentity.Identifier, "Error")
    return
}

# Update linked mailbox properties.
$linkedMailbox = $Context.BindToObject($linkedMailboxPath)
foreach ($propertyName in $propertiesToCopy)
{
    try
    {
        $value = $Context.TargetObject.Get($propertyName)
    }
    catch
    {
        $value = $NULL
    }
    
    $linkedMailbox.Put($propertyName, $value)
}

# Save changes
$linkedMailbox.SetInfo()

Comments 2

You must be signed in to comment.

  • Malcolm

    Malcolm

    In order to avoid errors when it hits an empty property, I have updated my script with a check for each property not being blank as follows:

    if("%department%" -ne ""){  
    $linkedMailbox.Put("Department", "%department%")}
    

    This then prevents the script from failing or throwing errors because a property was blank.

  • Support

    Support

    Hello Malcolm,

    Thank you for pointing out the behavior. We updated the script to clear linked mailbox properties if the corresponding properties of the master account are empty. If you need the linked mailbox properties to remain as is in such cases, you can keep using the script with your code.

    Also, we added a variable that is used to specify the properties to update.

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.