I had the need to enable forwarding for large batches of users to an external domain in one go. I came up with this.
1. Create a CSV file containing UPN and external email adrress.
forwarding.csv:
UPN,EmailAddress
Daniel.Noakes@noak.es,daniel.noakes@exchangegeek.com
2. Create a PowerShell script using the following.
Import-Csv Forwarding.csv ForEach {New-MailContact -Name $_.EmailAddress -ExternalEmailAddress $_.EmailAddress}
Import-Csv Forwarding.csv ForEach {Set-MailContact -Name $_.EmailAddress -HiddenFromAddressListsEnabled $true}
Import-Csv Forwarding.csv ForEach {Set-Mailbox -Identity $_.UPN -ForwardingAddress $_.EmailAddress -DeliverToMailboxAndForward $FALSE}