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
No matter what I do, the output never gets fully populated. I get a csv with the headers for Display name, Primary SMTP addresss, and SIP, but the SMTP and SIP columns are blank.
Hi Felix,
Are you using the exact same code as above? Those two properties should get populated, at the least the SMTP one. Try printing them while the script runs and check what you get. For example, instead of:
If ($_.IsPrimaryAddress -and $_.Prefix -match “SMTP”) { $strPrimaryAddress = $_.SmtpAddress }
If ($_.PrefixString -eq “sip”) { $strSIP = $_.AddressString }
try:
If ($_.IsPrimaryAddress -and $_.Prefix -match “SMTP”) { $strPrimaryAddress = $_.SmtpAddress; $strPrimaryAddress}
If ($_.PrefixString -eq “sip”) { $strSIP = $_.AddressString; $strSIP}
Regards,
Nuno
block CSV in both options
Can you please test this script because I am not getting any result.
I have used it many times before in different environments and have never had any problems… Try the suggestion I made in my previous comment to Felix.
It worked. I was running from remote PS. You need to run on the exchange server.