Monday, November 19, 2007

How to configure mail forwarding in Exchange 2007

 

This procedure describes how to configure a mailbox to forward mail to either a mail-enabled contact or another mailbox. It can be configured through GUI (EMS - exchange Management Console) but here I'll show how to do it via PowerShell (EMS - Exchange Management Shell).

 

$srcMbx="Test"  # forward copy of all messages from this mailbox
$dstMbx="ShayL"  # mailbox to receive forwarded messages from source mailbox

 

# list forwarded mailboxes for user "Test" (default settings for new mailbox, no one)

PS > Get-Mailbox -Identity $srcMbx | fl deliver*,forward*

DeliverToMailboxAndForward : False
ForwardingAddress          :

 

# Set forward messages (copy) to ShayL mailbox

Set-Mailbox -Identity $srcMbx -DeliverToMailboxAndForward $true;
Set-Mailbox -Identity $srcMbx -ForwardingAddress $((get-mailbox -Identity $dstMbx).DistinguishedName);

 

# Check again

PS > Get-Mailbox -Identity $srcMbx | fl deliver*,forward*

DeliverToMailboxAndForward : True
ForwardingAddress          : DomainName/Users/Shay Levy

 

 
### EDIT ###
The command can be issued as a one liner:

Set-Mailbox user -DeliverToMailboxAndForward:$True -ForwardingAddress name@domain.com

###########

 

# Check the GUI, Exchange > Recipient Configuration > Mailbox > Test

forward

8 comments:

Deepak said...

what is the script for disabling mail forwarding?

$hay@Israel said...

Clear the ForwardingAddress property:

Set-Mailbox -Identity userName -ForwardingAddress $null

Roger said...

Let's say I want to know if a forwarder has been set on a mailbox, how would I use this script? (for all mailboxen on a server)

$hay@Israel said...

Hi Roger,

The info you're looking for is a mailbox ForwardingAddress property. This will list all mailboxes which has this attribute set (Name and ForwardingAddress).


Get-Mailbox -resultSize unlimited -Filter {ForwardingAddress -ne $null} | select Name,ForwardingAddres

Roger said...

Excellent! Thanx!

Seamus said...

Hi
Thanks for this post. I have been asked to put a powershell script together to find out who has alt recipient set from a list in a csv file. This csv file will contain a list of smtp addresses to search against do you know how I will go about doing this

$hay@Israel said...

That should be fairly easy, say you have a csv file with one column 'email' and below a list of email addresses:

Import-Csv emails.csv | Get-Mailbox -Identity {$_.email} | where {$_.forwardingAddress -ne $null}

Seamus said...

Thank you very much for your help much appreciated you have helped me get out of a big hole once again much appreciated