The following steps will add a new alias to given emails. It will not make the new alias as primary.
- Open a persistant session to the exchange.
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection
02.Import the session to your powershell:
Import-PSSession $Session
03.Login to Microsoft 365 admin account
Connect-Msolservice
- Download Global address list.
get-user -resultsize unlimited |select * |export-csv c:\M365\users.csv - Delete all columns except “Identity”.
- Add a new column named “Alias”.
- After updating the sheet run the following script.
$Recipients = Import-Csv C:\M365\users.csv
Foreach ($Item in $Recipients)
{
Set-Mailbox -Identity $Item.Identity -EmailAddresses @{Add=$Item.Alias}
}
(This note is based on what I did today. I have very little understanding of powershell, if you are going to try these steps please do your research first.)