How-To Technical

Add multiple SMTP aliases | Exchange Online

The following PowerShell script will add multiple SMTP aliases to all Office 365 and Exchange Online email user accounts:

# Import the Exchange Online module
Import-Module ExchangeOnlineManagement

# Connect to Exchange Online

# Get all Office 365 and Exchange Online email user accounts
$users = Get-User -Filter "RecipientTypeDetails -eq 'MailUser'"

# Define the SMTP aliases to add
$smtpAliases = @("alias1@$", "alias2@$", "alias3@$")

# Add the SMTP aliases to each user account
foreach ($user in $users) {
    foreach ($smtpAlias in $smtpAliases) {
        Set-User -Identity $user.Identity -Alias $smtpAlias

# Disconnect from Exchange Online

To use the script, save it as a .ps1 file and run it from a PowerShell console with administrator privileges. For example, if you saved the script as add-multiple-smtp-aliases.ps1, you would run it with the following command:


The script will add the SMTP aliases defined in the $smtpAliases variable to all Office 365 and Exchange Online email user accounts. You can modify the $smtpAliases variable to include any SMTP aliases that you want to add.

Note: You can also use the Exchange admin center to add multiple SMTP aliases to an Office 365 or Exchange Online email user account. To do this, navigate to Users > Active users and select the user account that you want to add the aliases to. Then, click Edit and scroll down to the Email addresses section. Click the Add button and enter each SMTP alias that you want to add.

Lastly, please check this in a dev envionment. I am not a .ps expert, just sharing what worked for me.

Leave a Reply

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

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