PowerShell: Bulk Forwarding Script

Here’s another handy script in my migration toolbelt – one of my very frequent tasks during different types of migration projects is to configure forwarding on mailboxes. Often times you might be forwarding in one direction for the duration of the backend migration, and then after cutover, you might need to remove that forwarding and start forwarding in the other direction (source to target, cut-over, target to source).

Like most things, if I end up having to do it more than once or twice, I’m going to script it and keep that script close for whenever I need to reuse it. I always find it helpful to keep a repository of all my migration scripts as I find I’m often going back to them and pulling sections forward into new scripts.

Start by building yourself a CSV file – you only need two columns: UserPrincipalName and ForwardingAddress.

This script has only one required parameter, and that’s the CSV file – if you run the script without any other switches, it’ll import your user list, check their forwarding information and report it back to you.

Getting info only: .Bulk-Forwarding.ps1 -CSV c:scriptsusers.csv

(make sure you update the paths as necessary so the script can find your CSV file.)

The other two switches available to you are -SetForwarding, and -RemoveForwarding, which do exactly what it sounds like they do – set or remove the SMTP forwarding from a user’s account.

Setting forwarding: .Bulk-Forwarding.ps1 -CSV c:scriptsusers.csv -SetForwarding

And then finally, to remove the forwarding: .Bulk-Forwarding.ps1 -CSV c:scriptsusers.csv -RemoveForwarding

Not overly complicated, but robust enough to do the job, and a great timesaver! If you’re interested, head over to GitHub and download the script – feel free to check out the other scripts I have posted there as well. If you have any questions, leave a comment below, or even just to let me know this was helpful.

Good luck; have fun!


3 thoughts on “PowerShell: Bulk Forwarding Script

    1. Hi Jonathan,
      You can only forward to multiple email addresses using mailbox rules in the mailbox itself, or by creating a distribution list in Exchange Online and then forwarding to that instead of a single user.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.