I have scoped down you answer and make it clearly for you question :
-> Do You Need DisplayName or Password?
No — not in the second CSV that’s only used by PowerShell to add aliases.
You only needed DisplayName and Password in the first CSV when uploading to the Admin Center (which handles creating the users and assigning passwords).
Once the users are created, you only need the fields relevant for the script — so your second CSV can be trimmed to just:
UserPrincipalName,Email1,Email2
@mydomain.org,@mydomain.mail.onmicrosoft.com,*****@mydomain.onmicrosoft.com*
@mydomain.org,@mydomain.mail.onmicrosoft.com,*****@mydomain.onmicrosoft.com*
...
-> Is the script correct? And how does the data fit?
Yes, this script is correct:
Import-Csv "alias-list.csv" | ForEach-Object {
$UPN = $_.UserPrincipalName
$Email1 = $_.Email1
$Email2 = $_.Email2
Set-Mailbox -Identity $UPN -EmailAddresses @{add=$Email1}
Set-Mailbox -Identity $UPN -EmailAddresses @{add=$Email2}
}
-> And What goes in the CSV?
As your note:
- Yes, each Email1 and Email2 value should be the full address (e.g., ******@mydomain.mail.onmicrosoft.com).
- There’s no need to include a display name in this second CSV.
- Each row is one user; just make sure the values are accurate.
-> So your Workflow it should looks like this steps:
Step 1 — Create users in M365 Admin Center:
- Download and populate Microsoft’s sample CSV with fields like DisplayName, Username, and Password.
- Upload that CSV in Admin Center > Users > Add Multiple.
Step 2 — Prepare second CSV (for PowerShell):
- Create a simple alias-list.csv like this:
UserPrincipalName,Email1,Email2
@mydomain.org,@mydomain.mail.onmicrosoft.com,*****@mydomain.onmicrosoft.com*
@mydomain.org,@mydomain.mail.onmicrosoft.com,*****@mydomain.onmicrosoft.com*
...
Step 3 — Run the PowerShell script:
Open PowerShell as admin, connect to Exchange Online:
Connect-ExchangeOnline
Then run the alias update:
Import-Csv "alias-list.csv" | ForEach-Object {
$UPN = $_.UserPrincipalName
$Email1 = $_.Email1
$Email2 = $_.Email2
Set-Mailbox -Identity $UPN -EmailAddresses @{add=$Email1}
Set-Mailbox -Identity $UPN -EmailAddresses @{add=$Email2}
}
-> This will add the two aliases for each user automatically
You don’t need to set @mydomain.mail.onmicrosoft.com as a secondary alias (Exchange Online routes via UPN by default), but it's good practice for hybrid-like consistency.
- You can confirm aliases with:
*Get-Mailbox *****@mydomain.org | Select-Object -ExpandProperty EmailAddresses
- If aliases already exist, Set-Mailbox won’t overwrite — it just appends.
I hope this information will help you