Quick Tip – Find users with specific email domain using PowerShell

5315.powershell-logo.gif-550x0

Do you ever find yourself needing to find users with a specific email domain in Exchange but find yourself battling the correct syntax with the filter command, or waiting ages for it to get through all your objects using the Where-Object command? The following one-liner quickly produces a list of users who’s primary email address is a specific domain.


In order for you to find users using PowerShell, all you need to do is enter this command;

 

Find a Mail User

Get-MailUser -Filter { WindowsEmailAddress -like “*@example.com” }

Find a Mailbox

Get-Mailbox -Filter { WindowsEmailAddress -like “*@example.com” }

 

CONCLUSION:

Using the above command you can quickly collect a list of users, export them to CSV using | Export-CSV or copy your data straight to the clipboard using | clip and post it into your documents/files.

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s