This script is a variant from my previous post. It will allow you to set the forwarding property on a mailbox list, specified in a CSV file. The principle remains the same. You can download it here .
- Exchange Online Admin credentials.
- A log file path, which will contains the potentials errors during the script execution, but also the succeful actions.
- A CSV file using ; as delimiter. The CSV file needs to looks like the following :
The first colums must contains the User ID or user principal name (UPN), the second column must containsa valid email adress where the mails will be redirect.
The third column must contains the DeliverToMailboxAndForward parameter which specifies the message delivery behavior when a forwarding address is specified by the ForwardingAddress or ForwardingSmtpAddress parameters. Valid values are:
$trueMessages are delivered to this mailbox and forwarded to the specified recipient or email address.
$falseIf a forwarding recipient or email address is configured, messages are delivered only to the specified recipient or email address, and messages aren’t delivered to this mailbox. If no forwarding recipient or email address is configured, messages are delivered only to this mailbox.
The default value is
$false. The value of this parameter is meaningful only if you configure a forwarding recipient or email address.
Source : https://technet.microsoft.com/en-us/library/bb123981(v=exchg.160).aspx
- Open Windows PowerShell
- Run the Set-Forwarding.ps1
- Enter the Credential which is at least Exchange Online Administrator, then click OK.
- Enter your log file path, and your CSV forwarding list :
- Then click Enter to start the script.
- You can then check the results by using the Get-MailBox upn | Select ForwardingSmtpAddress, DeliverToMailboxAndForward
The log file, that you will specified will contains all the actions made by the script.
Output Exemple 1
In this exemple, i have specified a bad file path or name for my CSV file.
Output Exemple 2
In this exemple, The log file informs you that the forwarding for the specified mailbox was successfully configured.