Exchange Online – Find Mailboxes With Specific Domain

In this blog post, I will show you how to find users in Office 365 Exchange Online with a specific email domain.

You might be asked to find users with that have an email domain set as an SMTP Alias.

Exchange Online PowerShell allows us to manage Exchange recipients and automate tasks.

In my case, I have a group of users, I need to remove their SMTP alias, and I want to find them and produce a CSV file.

Connect to Exchange Online PowerShell

The first step in this process is to connect to Exchange Online using PowerShell and the best way to do it is using Cloud Shell.

In my previous post, I showed how to use it.

Once connected, I will run the following command that will output a list of users with the domain of ntweekly.com (change to match your domain)

Get-Mailbox -ResultSize unlimited | where {$_.emailAddresses -like "*@ntweekly.com" }

To export the result to a CSV file run the following command.

Get-Mailbox -ResultSize unlimited | where {$_.emailAddresses -like "*@ntweekly.com" } | Export-csv name.csv

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.