Script Repository

Automatically update SIP address

February 18, 2021

The script automatically sets a user's SIP address the same as the primary SMTP address.

To use the script with Adaxes, you need to create a business rule triggered after modifying Exchange properties of a user that runs the script using the Run a program or PowerShell script action.

For more information on modifying mailbox addresses using Adaxes ADSI API, see E-Mail Addresses.
Edit Remove
# Get Exchange properties
$mailboxParams = $Context.TargetObject.GetMailParameters()
$emailAddresses = $mailboxParams.EmailAddresses

# Get current SIP addresses
$sipAddresses = $emailAddresses.GetAddressesByPrefix("sip")
if ($sipAddresses.Length -eq 0)
    return # The user doesn't have a SIP address
elseif ($sipAddresses.Length -gt 1)
    $Context.LogMessage("Found more than one SIP address", "Warning")

# Get primary SMTP address
$smtpAddresses = $emailAddresses.GetAddressesByPrefix("smtp")
foreach ($smtpAddress in $smtpAddresses)
    if (-not($smtpAddress.IsPrimary))
    $primaryAddress = $smtpAddress.Address

# Compare Primary SMTP and SIP addresses
$sipAddress = $sipAddresses[0]
if ($sipAddress -ieq $primaryAddress)
    return # Primary SMTP address was not changed

# Change SIP Address
$sipAddress.Address = $primaryAddress

# Save changes
$mailboxParams.EmailAddresses = $emailAddresses
$Context.TargetObject.SetMailParameters($mailboxParams, "ADM_SET_EXCHANGE_PARAMS_FLAGS_NONE")

Comments ( 0 )
No results found.
Leave a comment