Compare Primary SMTP address with SIP address

by Nuno Mota [Published on 6 Dec. 2011 / Last Updated on 28 Nov. 2011]

If you have an Exchange environment as well as Office Communications Server or Lync, you might have users which had their e-mail address updated but their SIP address remained the same... For a quick way to find these users, you can use the following script:


[String] $strPrimaryAddress

[String] $strSIP

[Array] $arrCollection = @()


ForEach ($mbx in (Get-Mailbox -ResultSize Unlimited))


       # Initialize object to hold all the information

       $mbcomb = "" | Select "Display Name", "Primary SMTP Address", "SIP"


       # Reset variables

       $strPrimaryAddress = $strSIP = $NULL


       # Check all the e-mail aliases the user has

       $mbx.EmailAddresses | ForEach {

              If ($_.IsPrimaryAddress -and $_.Prefix -match "SMTP") { $strPrimaryAddress = $_.SmtpAddress }

              If ($_.PrefixString -eq "sip") { $strSIP = $_.AddressString }



       # Compare the primary SMTP with the SIP address

       If ($strPrimaryAddress -ne $strSIP)


              $mbcomb."Display Name" = $mbx.DisplayName

              $mbcomb."Primary SMTP Address" = $strPrimaryAddress

              $mbcomb."SIP" = $strSIP


              $arrCollection += $mbcomb




# Print or export all the results

$arrCollection | FT

#$arrCollection | Export-Csv D:\Scripts\"SMTPvsSIP_$(Get-Date -f 'yyyyMMdd').csv" -NoType

See Also

See Also

Featured Links