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 21
Who is Participating?

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

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.

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.
Jason CrawfordTransport NinjaCommented:
Is this what you mean?

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

Open in new window

Jason CrawfordTransport NinjaCommented:
And for the second part:

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

Open in new window

Exploring SQL Server 2016: Fundamentals

Learn the fundamentals of Microsoft SQL Server, a relational database management system that stores and retrieves data when requested by other software applications.

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
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?
No, I don't believe so.
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 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

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:/*"'
Try this:
Get-Mailbox -Filter 'PrimarySmtpAddress -notlike "*x500:*"'

Open in new window

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