/ PowerShell

Exchange, Add a SIP Address to Match the Users Email Address

Problem:

You need to update all your user mailboxes so that their SIP address matches their PrimarySMTPAddress. PowerShell!

Solution:

# First grab all the user mailboxes.
# ADJUST THIS TO SUIT YOUR NEEDS!
$mbxes = Get-Mailbox -ResultSize unlimited -RecipientType UserMailbox

# Set a counter.
$i = 0

# Now, loop through each mailbox and set the SIP address to match the PrimarySMTPAddress.
ForEach ($mbx in $mbxes) { 
    
    # Build up the SIP Address.
    $newSIP = 'SIP:' + $($mbx.PrimarySmtpAddress) 
    Write-Host -ForegroundColor Cyan -NoNewline "SET MAILBOX: $($mbx.SamAccountName) :: SIP ADDRESS :: "

    try {
        # Add the SIP Address. 
        Set-Mailbox -Identity $mbx.SamAccountName `
            -EmailAddresses @{ Add = $newSip } `
            -ErrorAction Stop -Whatif
        Write-Host -ForegroundColor Cyan " | SUCCESSFUL :)"

    } # END-TRY
    catch {
        Write-Warning " | FAILED :("
        Write-Warning $Error[0].Exception.Message

    } # END TRY/CATCH   
    
    # Show progress of processed mailboxes.
    $i++
    Write-Progress -Activity "Working..." `
        -Status "Progress: $i of $($mbxes.Count) " `
        -PercentComplete ($i / $mbxes.Count * 100)

} # END FOREACH ($mbx in $mbxes)

Summary

Note, the use of the -WhatIf parameter. Any 'Set' action should be tested. Once you are happy with the results remove the -WhatIf :D
Happy coding!

Steve Rackham

Steve Rackham

By day, IT professional with advanced skills across a broad spectrum of technology stacks and enterprise platforms. By night, happiest learning while tinkering under the hood and writing :)

Read More
Exchange, Add a SIP Address to Match the Users Email Address
Share this