Add email alias to multiple O365 user accounts in bulk


Hello team,


We currently have a domain:

We are going to add a new domain:

users are in-cloud.

We want to add email aliases to some of our users as and set it as primary.


however I didnt find any script which will do this in bulk for multiple users.

I found a script which does for all users however we just have to apply the script for 60-70 users.

Any help would be appreciated


3 Replies

So simply adapt the script to run against just the users in question, either by using filter or by feeding a CSV file to the script. Here's a simple example:


Import-CSV blabla.csv | %  {Set-Mailbox $_.UserPrincipalName -WindowsEmailAddress $_.NewAddress }


where the blabla.csv file has a column UserPrincipalName to identify the users, and a column NewAddress to specify the new primary SMTP address.

@Test SharePoint 


An added info : In your environment, if you guys maintain same value for user's PrimarySmtpAddress and UserPrincipalName, then you can use the below command to set Primary Email Address and UserPrincipalName in same command.

Import-CSV blabla.csv | %  {
Set-Mailbox $_.UserPrincipalName -WindowsEmailAddress $_.NewAddress -MicrosoftOnlineServicesID $_.NewAddress

In Office 365 cloud environment, you should care about the mismatch of UPN and Email address, because users need to use their UPN (UserPrincipalName) as login name to sign-in to Office 365 apps. You can refer this post for more info.

Hi Vasil,

Just wanted to check with you if it is possible to add to all users/sharedmailbox/DL/secgroup and Teams that have only our tenant has multidomain and we want to update only.