Set multiple mailbox forwarding in Office 365 using a CSV file


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 .


  1. Exchange Online Admin credentials.
  2. A log file path, which will contains the potentials errors during the script execution, but also the succeful actions.
  3. 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:

  • $true   Messages are delivered to this mailbox and forwarded to the specified recipient or email address.
  • $false   If 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 :


  1. Open Windows PowerShell
  2. Run the Set-Forwarding.ps1
  3. Enter the Credential which is at least Exchange Online Administrator, then click OK.
  4. Enter your log file path, and your CSV forwarding list :
  5. Then click Enter to start the script.
  6. 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.