Setting forwards manually can be a daunting task if you have a lot of users in an environment. Thankfully, PowerShell lets you do this in bulk and save loads of time!

To get started, create a CSV with two headers - UPN and FWD. Add the users addresses that you want to set forward on in the UPN column and add the forwarding addresses in the FWD column. Be especially careful to ensure that these addresses line up correctly. Forwarding mail to the wrong users mailbox is a big deal and something you'll definitely want to avoid at all costs. Now save the file and give it the name fwds.csv and take note of the directory location that you save it to.

Next, we'll need to establish a remote PowerShell session with the O365 cloud and import and connect to the MSolservice module. Use the PowerShell below to do this.

Set-ExecutionPolicy RemoteSigned
Set-ExecutionPolicy Unrestricted
$LiveCred = Get-Credential
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell/ -Credential $LiveCred -Authentication Basic -AllowRedirection
Import-PSSession $Session 
Connect-MsolService
Import-Module Msonline

Now that we've got a remote PowerShell session going, let's navigate to the directory that our fwds.csv file lives in using the following command:

cd "C:\Users\ExampleUserName\Documents"

Now let's check to make sure the file is there by running the ls command

ls

You should see feedback that looks something like this after running the command:

PS C:\Users\ExampleUserName\Documents> ls

    Directory: C:\Users\ExampleUserName\Documents
    
Mode                LastWriteTime         Length Name
----                -------------         ------ ----     
-a----        1/22/2020  9:51 PM           3973 fwds.csv 

Provided you see your file there, you're now good to proceed to the next step by running the multiple user forwarding code below .

$users = import-csv '.\fwds3.csv'
foreach ($user in $users)
{
    Set-Mailbox $user.UPN –ForwardingSmtpAddress $User.FWD -force
 
    Write-Host "$($user.UPN) now forwards to ($user.FWD)"
}
$users = $null

If everything is formatted properly, you should see successful feedback that looks like this:

[email protected] now has the alias of (@{[email protected]; [email protected]}.FWD)

That's it, you're done!