List all Mailbox Missing a x500 string that Contains..

I am trying to get a list of all mailboxes that are missing an X500 string that contain or starts with specific letters and another script that will list which X500 is marked as primary.

I have tried using get-mail -Filter{EmailAddress  -notlike"*something8"} as an example which does run but returns all X500's.

Any suggestions.
LVL 20
compdigit44Asked:
Who is Participating?
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.

RoninCommented:
Well at the end of the command type
 .... | fl Name

Open in new window

Which will produced the named list of users which have that address.
Next, run the same command producing the list of all users.
Export the provided lists to Notepad++, sort alphabetically and compare.
Remove the ones which appear in both lists.
It's only one out of possible approaches.
0
Jason CrawfordTransport NinjaCommented:
Is this what you mean?

Get-Mailbox -Filter 'EmailAddresses -like "x500:*"'

Open in new window

0
Jason CrawfordTransport NinjaCommented:
And for the second part:

Get-Mailbox -Filter 'PrimarySmtpAddress -like "*x500*"'

Open in new window

0
Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

compdigit44Author Commented:
THe problem is that I am trying to use  -notlike which seem to be return all x500 values that match and do not match
0
compdigit44Author Commented:
On a side note, in a hybrid setup with Exchange 2010 and Office 365, with 95% of our mailboxes now in the cloud, does it really matter which X500 is listed as primary?
0
RoninCommented:
No, I don't believe so.
0
Jason CrawfordTransport NinjaCommented:
I'm not aware of any circumstance, even in a hybrid setup with Exchange Online, where the x500 should be the PrimarySmtpAddress.  The x500 is only added as an alias to account for cached Autocomplete entries in Outlook.  All other mail routing will be determined either by the primary address or the targetAddress (generally a onmicrosoft.com address) in AD.

In any case, either of these should work

Get-Mailbox -Filter 'EmailAddresses -notlike "x500:*"'

Get-Mailbox | Where-Object {$_.EmailAddresses -notlike 'x500*'}

Open in new window

0
compdigit44Author Commented:
The first command seemed to work but second command listed all maiboxes if they matched or did not.  Also this command only disapyed the primary SMTP address not the X500.

Get-Mailbox -Filter 'PrimarySmtpAddress -like "x500:/*"'
0
RoninCommented:
Try this:
Get-Mailbox -Filter 'PrimarySmtpAddress -notlike "*x500:*"'

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
RoninCommented:
You should award Jason with points as well, as you have used his answer as well.
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
Office 365

From novice to tech pro — start learning today.

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.