RSS

Bulk add alias in Microsoft 365 Exchange using powershell.

31 May

The following steps will add a new alias to given emails. It will not make the new alias as primary.

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

  1. Download Global address list.
    get-user -resultsize unlimited |select * |export-csv c:\M365\users.csv
  2. Delete all columns except “Identity”.
  3. Add a new column named “Alias”.
  4. 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.)

 
Leave a comment

Posted by on May 31, 2021 in Uncategorized

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

 
%d bloggers like this: