Bulk add alias name by using script

Bulk add alias name by using script

Before we can run the script, we need to connect to exchange online powershell.

Set-ExecutionPolicy RemoteSigned
$UserCredential = Get-Credential
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection
Import-Module ExchangeOnlineManagement; Get-Module ExchangeOnlineManagement
Update-Module -Name ExchangeOnlineManagement

————- add alais name to email ————–

Import-CSV “D:\RemoveAlias.csv” | ForEach {Set-Mailbox $_.OldEmailAddress -EmailAddresses @{add=$_.NewEmailAddress}}

————- remove alais name from email ————
Import-CSV “D:\RemoveAlias.csv” | ForEach {Set-Mailbox $_.OldEmailAddress -EmailAddresses @{Remove=$_.NewEmailAddress}}
———————–remove domain————

create alias with csv file

OldEmailAddressNewEmailAddress
sin1@vmotion.sitesin1@o365.vmotion.site

Leave a Reply

Your email address will not be published. Required fields are marked *