Sometimes, we add a new domain to Microsoft 365 and we want to have a domain alias for multiple or every user.


Logging in Exchange Online Powershell

To configure a alias for every user, we need to login into Exchange Online Powershell:

PowerShell
Connect-ExchangeOnline

If you don’t have the module already installed on your computer, run the following command on an elevated window:

PowerShell
Install-Module ExchangeOnlineManagement

Source: https://www.powershellgallery.com/packages/ExchangeOnlineManagement/3.7.2

Adding the 365 domain alias to every user

After succesfully logged in, run the following command:

PowerShell
$users=Get-Mailbox | Where-Object{$_.PrimarySMTPAddress -match "justinverstijnen.nl"}

Here our current domain is “justinverstijnen.nl” but let’s say that we want to add “justinverstijnen.com”. Run the following command to do this:

PowerShell
foreach($user in $users){Set-Mailbox $user.PrimarySmtpAddress -EmailAddresses @{add="$($user.Alias)@justinverstijnen.com"}}

Now we have added the alias to every user. To check if everything is configured correctly, run the following command:

PowerShell
$users | ft PrimarySmtpAddress, EmailAddresses


End of the page 🎉

You have reached the end of the page. You can select a category, share this post on X, LinkedIn and Reddit or return to the blog posts collection page. Thank you for visiting this post.

If you think something is wrong with this post or you want to know more, you can send me a message to one of my social profiles at: https://justinverstijnen.nl/about/

Go back to Blog

The terms and conditions apply to this post.

Page visitors: No page-counter data available yet.

1 Comment

Michaeltiday · June 27, 2025 at 13:18

Thanks, exactly what i needed

Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *