Especially during a messaging migration, situations may arise where external message forwarding has to be set up for several users.

One of the reasons, given as an example, may be that the affected users have to be migrated to a new tenant and a new primary SMTP has to be used on this tenant.
To be more precise: The company Fabrikam was bought by Contoso and the users have to be migrated on the one hand, and on the other hand all users of Fabrikam get the @contoso.com mail domain as primary SMTP address.

I have already described how to migrate in my article:

However, if the Fabrikam users have to work with the new mailbox and the new primary SMTP from now on, they will connect to the new mailbox.
In this scenario, the mail content migration can run independently of this.

 

In this article, I will show you a way of carrying out the mail content migration as a “silent big bang”.

The longer the users work with the new mailbox, the less important the old mail address becomes (for the mail flow).
It is therefore advisable to set up forwarding to the new mail address (new tenant) for the old mail address (old tenant).
For individual users, this can be easily implemented via the Exchange online Admin Centre.
For multiple users, the PowerShell is a useful tool.
The prerequisite for this is that the corresponding Exchange online PowerShell module has been installed.

One variant is to use the following script:

# List of Users and their forwarding addresses

$users = @{
    "[email protected]" = "[email protected]"
    "[email protected]" = "[email protected]"
}

# Setup forwarding

foreach ($user in $users.GetEnumerator()) {
    Set-Mailbox -Identity $user.Name -ForwardingSmtpAddress $user.Value -DeliverToMailboxAndForward $True
    Write-Host "Forwarding for $user.name is set!" -ForegroundColor Green
}

 

This works for a large number of users.
However, if you prefer to work with a CSV file, the script in the following link might help you.

 

You can find details about the script in the corresponding README in the repository. Basically, the script can be executed without modification.
The required CSV file needs the following values:
“Name”, “SMTPold”, “SMTPnew”

 

I hope this article prevents future headaches 🙂