How to bulk add new domain to mailbox address in Exchange Online
Introduction
This script will bulk add new domain to mailbox address in Exchange Online.
Scenarios
This script will bulk add new domain to mailbox address in Exchange Online.
Script
You can use this script in the following way.
1. Open Windows PowerShell.
2. Type the one command< Script Path> at the Windows PowerShell Console.
For example, type C:\Script\ EXOBulkAddDomainsToMailbox.ps1
Here are some code snippets for your references.
Foreach($Domain in $domains)
{
$NewAddress += $Identity +"@"+ $domain
}
Set-Mailbox -identity $Box.PrimarySmtpAddress -EmailAddresses @{add = $NewAddress}
Foreach($Domain in $domains)
{
$NewAddress += $Identity +"@"+ $domain
}
Set-Mailbox -identity $Box.PrimarySmtpAddress -EmailAddresses @{add = $NewAddress}
Example1: Two domains "contoso1.com" and "contoso2.com" were added to this tenant. Use this script to add the two domains to mailbox address.
The sample is showed below
EXOBulkAddDomainsToMailbox.ps1 -Credential $Credential –Domains 'contoso1.com','
contoso2.com'
Prerequisites
Exchange Online
Windows PowerShell 2.0
Microsoft All-In-One Script Framework is an automation script sample library for IT Professionals. The key value that All-In-One Script Framework is trying to deliver is Scenario-Focused Script Samples driven by IT Pros' real-world pains and needs. The team is monitoring all TechNet forums, IT Pros' support calls to Microsoft, and script requests submitted to TechNet Script Repository. We collect frequently asked IT scenarios, and create script samples to automate the tasks and save some time for IT Pros. The team of All-In-One Script Framework sincerely hope that these customer-driven automation script samples can help our IT community in this script-centric move.