Add email alias to multiple O365 user accounts in bulk

%3CLINGO-SUB%20id%3D%22lingo-sub-909534%22%20slang%3D%22en-US%22%3EAdd%20email%20alias%20to%20multiple%20O365%20user%20accounts%20in%20bulk%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-909534%22%20slang%3D%22en-US%22%3E%3CP%3EHello%20team%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EWe%20currently%20have%20a%20domain%3A%20abc.com%3C%2FP%3E%3CP%3EWe%20are%20going%20to%20add%20a%20new%20domain%3A%26nbsp%3B%20xyz.com%3C%2FP%3E%3CP%3Eusers%20are%20in-cloud.%3C%2FP%3E%3CP%3EWe%20want%20to%20add%20email%20aliases%20to%20some%20of%20our%20users%20as%20user%40xyz.com%20and%20set%20it%20as%20primary.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Ehowever%20I%20didnt%20find%20any%20script%20which%20will%20do%20this%20in%20bulk%20for%20multiple%20users.%3C%2FP%3E%3CP%3EI%20found%20a%20script%20which%20does%20for%20all%20users%20however%20we%20just%20have%20to%20apply%20the%20script%20for%2060-70%20users.%3C%2FP%3E%3CP%3EAny%20help%20would%20be%20appreciated%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-909534%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EAdmin%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EEmail%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EOffice%20365%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EOffice%20365%20Admin%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EOffice%20365%20Email%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EOffice%20365%20Powershell%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-910727%22%20slang%3D%22en-US%22%3ERe%3A%20Add%20email%20alias%20to%20multiple%20O365%20user%20accounts%20in%20bulk%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-910727%22%20slang%3D%22en-US%22%3E%3CP%3ESo%20simply%20adapt%20the%20script%20to%20run%20against%20just%20the%20users%20in%20question%2C%20either%20by%20using%20filter%20or%20by%20feeding%20a%20CSV%20file%20to%20the%20script.%20Here's%20a%20simple%20example%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EImport-CSV%20blabla.csv%20%7C%20%25%26nbsp%3B%20%7BSet-Mailbox%20%24_.UserPrincipalName%20-WindowsEmailAddress%20%24_.NewAddress%20%7D%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3Ewhere%20the%20blabla.csv%20file%20has%20a%20column%20UserPrincipalName%20to%20identify%20the%20users%2C%20and%20a%20column%20NewAddress%20to%20specify%20the%20new%20primary%20SMTP%20address.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-912254%22%20slang%3D%22en-US%22%3ERe%3A%20Add%20email%20alias%20to%20multiple%20O365%20user%20accounts%20in%20bulk%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-912254%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F163419%22%20target%3D%22_blank%22%3E%40Test%20SharePoint%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSTRONG%3EAn%20added%20info%3C%2FSTRONG%3E%20%3A%20In%20your%20environment%2C%20if%20you%20guys%20maintain%20same%20value%20for%20user's%20PrimarySmtpAddress%20and%20UserPrincipalName%2C%20then%20you%20can%20use%20the%20below%20command%20to%20set%20Primary%20Email%20Address%20and%20UserPrincipalName%20in%20same%20command.%3C%2FP%3E%3CPRE%3EImport-CSV%20blabla.csv%20%7C%20%25%20%20%7B%0ASet-Mailbox%20%24_.UserPrincipalName%20-WindowsEmailAddress%20%24_.NewAddress%20-MicrosoftOnlineServicesID%20%24_.NewAddress%0A%7D%3C%2FPRE%3E%3CP%3EIn%20Office%20365%20cloud%20environment%2C%20you%20should%20care%20about%20the%20mismatch%20of%20UPN%20and%20Email%20address%2C%20because%20users%20need%20to%20use%20their%20UPN%20(UserPrincipalName)%20as%20login%20name%20to%20sign-in%20to%20Office%20365%20apps.%20You%20can%20refer%20%3CA%20href%3D%22https%3A%2F%2Fwww.morgantechspace.com%2F2018%2F03%2Fuserprincipalname-vs-e-mail-address.html%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ethis%3C%2FA%3E%20post%20for%20more%20info.%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
Contributor

Hello team,

 

We currently have a domain: abc.com

We are going to add a new domain:  xyz.com

users are in-cloud.

We want to add email aliases to some of our users as user@xyz.com 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

 

2 Replies
Highlighted

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.

Highlighted

@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.