Secrets from the Field – Windows PowerShell Part 3 – Mailbox Forwarding

Website relaunched and updated

Sometimes you come across situations that require a users corporate mailbox to be configured to forward out to an external mailbox account.  There are many situations within business organizations that can drive this need.

Before explaining how to configure the forwarding careful consideration should be done regarding the security risks to corporate data and communications by allowing it to automatically forwarded outside the organizations messaging system.  This article shares some of the risks that this configuration can introduce.

Mailboxes in Exchange Online can be configured to forward messages to an external email domain.  Forwarding can be configured through several different areas within Exchange Online. The user can configure forwarding through Outlook Web Access (OWA) options and administrators can configure this setting directly on mailboxes within the Exchange Online subscription.

For this article we will be focused on the command that can be used through PowerShell.  More information on how you can configure email forwarding through OWA or the administrative console is available here.   One challenge I have found when using the administrative GUI to configure email forwarding is that it uses a picker window.  Using this picker window only allows you to select from items located in the global address list.  Using this picker means that you can only select an internal mailbox or mail contact.  For some situations the technical requirement may be require forwarding to an mailbox for an external mail domain.  In order to satisfy this requirement we are not able to use the GUI administrative tools and need to set this configuration using PowerShell or having the users set this via the OWA options.  We will walk through using PowerShell to see how we can achieve this technical requirement with a simple command:

For these examples you must first connect PowerShell to Windows Azure AD.  For instructions on this see this article.

To check the current fowarding settings (if any) on the specified mailbox:

Get-Mailbox -Identity | FL Name,ForwardingSMTPAddress

With the use of the commands below you are forwarding all emails sent to to  The command switch -DeliverToMailboxandForward determines if the message should be stored in the mailbox of user or not.  Setting this value to $true a copy of the message is stored in the mailbox.  If you do not wish to leave a copy of the mail in Fred’s mailbox then set this value to $false.

Example 1: Set forwarding email to External recipient and save a copy of the message in the forwarding mailbox

Set-Mailbox -Identity -DeliverToMailboxAndForward $true -ForwardingSMTPAddress

Example 2: Set forwarding email to External recipient and do not save a copy of the message in the forwarding mailbox

Set-Mailbox -Identity -DeliverToMailboxAndForward $false -ForwardingSMTPAddress

About Larry Taylor

Innovative helps you balance your business requirements, service levels, staff and infrastructure to make your IT as effective as possible. Larry Taylor is a Senior Solutions Consultant at Innovative with a focus on Microsoft technologies. Since 2002, Larry has been recommending, deploying, and providing support for organizations to align technology solutions with their business needs.

Leave a Reply

Innovative Integration can help you optimize your IT infrastructure. Request a Consultation