Forum Discussion
Add email alias to multiple O365 user accounts in bulk
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
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.
- ZekeYeagerCopper ContributorHi Vasil,
Just wanted to check with you if it is possible to add domain2.com to all users/sharedmailbox/DL/secgroup and Teams that have only domain1.com our tenant has multidomain and we want to update domain1.com only. - jasoncluteCopper Contributor
VasilMichev
I need to do this exact thing (cloud)... can you tell me how to add a new domain as an alias email to all the users??- rdgraspenCopper Contributor
Our email address are firstname . Lastname @ olddomain Here is how I updated all of our email addresses.
get-aduser -Filter * | select samaccountname | Export-csv adusers.csv
Edit adusers.csv - Remove service accounts, etc and all accounts that should not be changed. Save.
Copy final list and put it in a text file - adusers.txt
Copy adusers.txt to Powershell folder
$adusers = get-contect adusers.txt
check $adusers - This should reflect the final list created in the csv file.
$adusers | Get-ADUser | ForEach-Object { Set-ADUser -EmailAddress ($_.givenName + '.' + $_.surna me + '@newdomain') -Identity $_ }
Get-ADUser -Properties * -Filter * | select name,samaccountname,emailaddress to check the results.
- Kevin_MorganIron Contributor
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.