Find if any user has more than 1 SMTP address. thats different from the one it actually needs to be.

Hi,

Find if any user has more than 1 SMTP address. thats different from the one it actually needs to be.
We have just migrated some users from one Exchange to another 2003 to 2007
its in a different forest. i want help with a script that can query every linked mailbox within an OU and all Ou's within it and find all email addresses with the smtp's that are different.
In smtp i will have something like this
Sha@plc.com
Sha@rlc.com
Sha@uic.com
Sha@rty.com
sharath@plc.com
So in the above sharath@plc.com is the different email smtp here

Regards
Sharath
LVL 11
bsharathAsked:
Who is Participating?
 
Chris DentConnect With a Mentor PowerShell DeveloperCommented:
Added -SizeLimit 0.

If you have this display name:

Chris Dent

It will look for any SMTP address that is not:

Chris.Dent@domain.com

The script simply replaces any spaces in the display name with dots for the search.

Chris
Get-QADUser -SearchRoot "OU=somewhere,DC=domain,DC=com" -SizeLimit 0 `
    -LdapFilter "(&(proxyAddresses=*)(displayName=*))" -IncludedProperties ProxyAddresses | `
  Select-Object DN, DisplayName, @{n='ProxyAddresses';e={ 
    $Label = $_.DisplayName -Replace " ", "\."
    [String]::Join(" ", $($_.ProxyAddresses | ?{ $_ -NotMatch "^(x500)|(smtp:$Label@)" })) }} | `
  ?{ $_.ProxyAddresses -ne $Null } | `
  Export-CSV "SomeFile.csv"

Open in new window

0
 
LearnctxEngineerCommented:
You can just return any users who have any EmailAddress with the plc.com domain in them, or does it need to be specifically targeted at SMTP addresses (ie, you may have a notes address or something with the plc.com domain)?

Get-Mailbox | ? {$_.EmailAddresses -match "\@plc.com$"}

Open in new window

0
 
bsharathAuthor Commented:
I need to find any user who may not match the display name
Say for example
My Display name is
Sharath yui
My email is
Sharath.yui@plc.com
As i have many other domains these are default
Sharath.yui@dev.com
Sharath.yui@some.com
if there is any other name other than mine i want the results
0
Protect Your Employees from Wi-Fi Threats

As Wi-Fi growth and popularity continues to climb, not everyone understands the risks that come with connecting to public Wi-Fi or even offering Wi-Fi to employees, visitors and guests. Download the resource kit to make sure your safe wherever business takes you!

 
Chris DentPowerShell DeveloperCommented:

That makes it a bit easier.

Chris
Get-QADUser -SearchRoot "OU=somewhere,DC=domain,DC=com" `
    -LdapFilter "(&(proxyAddresses=*)(displayName=*))" -IncludedProperties ProxyAddresses | `
  ?{ $_.ProxyAddresses -NotMatch "^(x500)|(smtp:$($_.DisplayName -Replace ' ', '.')@)" } | `
  Select-Object DN, Name, @{n='ProxyAddresses';e={ "$($_.ProxyAddresses)" }}

Open in new window

0
 
bsharathAuthor Commented:
Hi Chris
I get this
The term 'Get-QADUser' is not recognized as the name of a cmdlet, function, script file, or operable program. Check
 spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:12
0
 
Chris DentPowerShell DeveloperCommented:

Quest... you have to load the CmdLets... I'm sure we've been here before ;)

Chris
0
 
bsharathAuthor Commented:
I get the whole list of X400/X500/Smtp but not the exact mismatches. how can i route them to a txt file.
0
 
Chris DentPowerShell DeveloperCommented:

This version will export the entries that failed to match to "SomeFile.csv".


Get-QADUser -SearchRoot "OU=somewhere,DC=domain,DC=com" `
    -LdapFilter "(&(proxyAddresses=*)(displayName=*))" -IncludedProperties ProxyAddresses | `
  Select-Object DN, DisplayName, @{n='ProxyAddresses';e={ 
    $Label = $_.DisplayName -Replace " ", "."
    [String]::Join(" ", $($_.ProxyAddresses | ?{ $_ -NotMatch "^(x500)|(smtp:$Label@)" })) }} | `
  ?{ $_.ProxyAddresses -ne $Null } | `
  Export-CSV "SomeFile.csv"

Open in new window

0
 
bsharathAuthor Commented:
I get this

WARNING: This search was configured to retrieve only the first 1000 results. To retrieve more results, increase the
size limit using the -SizeLimit parameter or set the default size limit using Set-QADPSSnapinSettings with the
-DefaultSizeLimit parameter. Use 0 as the value of size limit to retrieve all possible search results.

But it gets all users to the file. But not just users who have multiple SMTP's
i want to find SMTP's that are different
0
 
bsharathAuthor Commented:
I will have same user with different email id's like
Sharath.yui@plc.com
Sharath.yui@yui.com
Sharath.yui@qwe.com
Sharath.yui@qqu.com

Are these 4 are valide. Anything other than these @ for the user is the ones that i need to find
0
 
Chris DentPowerShell DeveloperCommented:

I built it based on the criteria you defined.

Please give me an example including the "wrong" addresses if the code above isn't working for you.

Chris
0
 
bsharathAuthor Commented:
Thank you. I have all into an excel will dletee the common and then i get the mismatches. Solves the purpose
:-)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.