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

Automatically update SIP address

February 18, 2021 Views: 6017

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
PowerShell
# 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")
    return
}

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

# 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
Leave a comment
Loading...

Got questions?

Support Questions & Answers