Quick Tip – Mapping mailboxes to forwarding contacts

A reader of my blog contacted me the other day with the following question:

I am a contractor at my company which is being broken up because of investment developments. I need to do the following.

Company has about 4200 users total

About 1300 have gone to another company almost all of these have normal mailboxes in our existing organisation

  • They want to create mail enabled contacts for these users (that is why I downloaded your Contact Master Tool as it looks like it will work great for that
  • In their mailboxes they want to check the forward to also put in the forward to address

I think I am going to have to run Contact Master to do the contacts and run another script to do the “Forward Items” – is my thinking correct?

Is there a PowerShell script that you could help me with to take care of the checkbox and forward address?.

The good news is that this is very easy using PowerShell and a simple CSV file.

Structure of the CSV file

In order to use the script within this post you will need to build a CSV file that contains the following headers:

  • Mailbox – This is the alias of the Mailbox on your Exchange Server that you want to configure the forwarder for.
  • Forwarder – This is the alias of the contact that you wish to forward the mail onto.

And then add in the relevant Mailbox and Contact aliases – see below


The script

The following script can be pasted into a new PS1 file on your Exchange Server.


$FileName = $CSVFile
$UserInformation = Import-Csv $FileName

Foreach ($User in $UserInformation){

    $Mailbox = $User.Mailbox
    $Forwarder = $User.Forwarder

    Set-Mailbox -Identity $Mailbox -ForwardingAddress $Forwarder -DeliverToMailboxAndForward $DeliverToMailboxAndForward

Write-Host "Script Completed..." -ForegroundColor Green

Running the script

The script requires two parameters which are as follows:

  • CSVFile – This is the path to the CSV file that contains the mappings.
  • DeliverToMailboxAndForward – The value should either be $True or $False – if you select $True then messages will be delivered to the local mailbox and to the forwarder, if you select $false if you only wish for the mails to be sent onwards.

You can run the script by using the following format:

.\<name that you have given the script> –CSVFile <path to CSV> –DeliverToMailboxAndForward

If you need assistance – you can refer to the following post which explains how you can run PowerShell script files: http://www.telnetport25.com/2012/02/quick-tip-running-exchange-based-powershell-script-files-from-the-command-line-or-a-batch-file/

When the script has executed you should see the following output:


Hope that someone finds this useful.

Leave a Reply

Your email address will not be published. Required fields are marked *

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