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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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
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
Redefine Your Security with AI & Machine Learning

The implications of AI and machine learning in cyber security are massive and constantly growing, creating both efficiencies and new challenges across the board. Check out our on-demand webinar to learn more about how AI can help your organization!

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
Chris DentPowerShell 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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Programming Languages-Other

From novice to tech pro — start learning today.