Link to home
Start Free TrialLog in
Avatar of swolff1
swolff1Flag for United States of America

asked on

forward Exchange 2010 mailbox to an external mailbox in Power Shell

Hello,
I need to forward several mailbox in Exchange 2010 to  external  mailboxes and looking for a reliable script rather then configuring mail "Contact" and then forwarding. I will have several hundred mailboxes to forward soon.

Thank you in advance,

Sig
Avatar of swolff1
swolff1
Flag of United States of America image

ASKER

Email forwarding in Powershell
Avatar of Jason Crawford
The reason a MailContact is generally used for forwarding purposes in Exchange is because you can't set forwarding on a mailbox on the server level to a domain that isn't configured as an Accepted Domain.  How many different external addresses are you forwarding to?  

Here is an example of the one-liner you can run to configure forwarding:

Set-Mailbox <mailbox> -ForwardingAddress user@externaldomain.com -DeliverToMailboxAndForward $false

Open in new window

Can you give more detail, what exactly you are looking. Are you trying to forward specific email or all emails. Did you enable forward option at org level?
Avatar of swolff1

ASKER

Potentially there are around 700 mailboxes that I need to forward to an External (not accepted) domain.
I can generate .csv file with a list of all the forwarding (target) email addresses but this will be done in stages and would require several .csv files. I hope that answers your question.
Thank you.
Avatar of swolff1

ASKER

Hello Jason,

Just tested a script that you provided and it only works if I have an existing "Mail Contact" in place, without  Contact it doesn't work for me.

Thanks.
ASKER CERTIFIED SOLUTION
Avatar of Minecraft_ Enderman
Minecraft_ Enderman

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of swolff1

ASKER

Thank you for your reply. Once forwarding is setup, what's the command to stop forwarding if I need.
Avatar of Minecraft_ Enderman
Minecraft_ Enderman

Just remove forwarding address.

Import-Csv C:\users.csv | ForEach{Set-Mailbox $_.alias -ForwardingSMTPAddress $null}