Oct 11 2019 01:33 PM
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
Oct 12 2019 09:33 AM
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.
Oct 14 2019 05:25 AM
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.
Sep 24 2021 12:03 AM
Jun 14 2023 09:33 AM
@Vasil Michev
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??
Aug 18 2023 12:34 PM - edited Aug 18 2023 12:37 PM
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.