Manage Forward Mail by using PowerShell | Office 365 5/5 (3) 8 min read

In the current article, we review the use of the Forward email PowerShell command in Office 365 and Exchange Online environment.

Forward email rule as the name implies, enable to forward automatically each email that sent to a particular mailbox to an additional email address.

The “Destination recipient” (E-mail address) could be “internal Mailbox” meaning a recipient from our organization or external recipient, meaning – recipient doesn’t belong to the organization (there is a different PowerShell Parameter for each of the options).

An additional parameter is an option of leaving a copy of the email in the source recipient mailbox or just forward the email message.

PowerShell | Help & additional information

Running PowerShell commands in Office 365 based environment
To be able to run the PowerShell commands specified in the current article, you will need to create a remote PowerShell with Azure Active Directory or Exchange Online. In case that you need help with the process of creating a Remote PowerShell session, you can use the links on the bottom of the Article.

In this article, we will demonstrate a couple of scenarios for Mail Forwarding:

  1. Mail forwarding to an internal recipient: John and Suzan are recipients who belong to the office 365 domain names: o365info.com
  2. Mail forwarding to External recipient: John wants to forward each mail that he gets to an external email address: david@hotmail.com
  3. Additional scenarios are: Mail Forwarding in Bulk mode – the option of forwarding email to a destination email address for all the office 365 users and a nice trick of email forwarding that will implement for external contact object.

1. Set mail forwording

ADMIN Forwarding (ForwardingAddress)

ADMIN Forwarding (ForwardingAddress) – Forward Email to Recipient & SAVE local copy (Default)

PowerShell command syntax

PowerShell command Example

ADMIN Forwarding (ForwardingAddress) – Forward Email to Recipient DONT SAVE a local copy

PowerShell command syntax

PowerShell command Example

USER Forwarding (ForwardingsmtpAddress)

Admin Forwarding (ForwardingsmtpAddress) – Forward Email to Recipient & SAVE local copy (Default)

PowerShell command syntax

PowerShell command Example

Admin Forwarding (ForwardingsmtpAddress) – Forward Email to Recipient DONT SAVE a local copy

PowerShell command syntax

PowerShell command Example

Create External contact with internal email address + Forward email address (External Email Address)

Step 1: Create External contact with External email address

PowerShell command syntax

Step 2: Set External contact email address to internal email address and forwarding email address (External email address) PowerShell command syntax:

PowerShell command syntax

PowerShell command Example

Step 1: Create External contact with External email address

Step 2: Set External contact email address to internal email address and forwarding email address (External email address) PowerShell command syntax:

2. Display information about mailbox Forwarding settings

Display information about Specific Mailbox Forwarding settings

PowerShell command syntax

PowerShell command Example

Find all Recipients (Display list) with ADMIN Forwarding or USER Forwarding

PowerShell command Example

3. Disable (remove) E-mail Forwarding option

Disable (cancel) ADMIN Forwarding (ForwardingAddress) Specific MAILBOX

PowerShell command syntax

PowerShell command Example

Disable (cancel) USER Forwarding (ForwardingsmtpAddress) Specific MAILBOX

PowerShell command syntax

PowerShell command Example

Disable (cancel) ADMIN Forwarding (ForwardingAddress) ALL MAILBOXES (BULK mode)

PowerShell command Example

Disable (cancel) USER Forwarding (ForwardingsmtpAddress) ALL MAILBOXES (BULK mode)

PowerShell command Example

4. Export information about forwarding settings

Exoprt informaiton about USER Forwarding rule

Export to CSV file:
PowerShell command Example

Exoprt informaiton about ADMIN Forwarding rule

Export to CSV file:
PowerShell command Example

Exoprt informaiton about User inbox Forwarding rule

Export to CSV file:
PowerShell command Example

5. Forward Email of ALL Users to Additional email address (Bulk mode)

4.1 – Forward Email of ALL Users to internal Recipient & save local copy

PowerShell command Syntax

Step 1: Save local copy

Step 2: Forward email to the destination recipient (internal\organization recipient)

PowerShell command syntax

PowerShell command Example
Step 1: Save local copy

Step 2: Forward email to the destination recipient (internal\organization recipient)

4.2 – Forward Email of ALL Users to External Recipient & save local copy

Step 1: Save local copy

Step 2: Forward email to the destination recipient (internal\organization recipient)

PowerShell command syntax

PowerShell command Example
Step 1: Save local copy
Step 2: Forward email to the destination recipient (External recipient)

4.3 – Forward Email to External Recipient & save local copy | import from CSV File |Scenario 1

Step 1: Enable to option of DeliverToMailboxAndForward

Step 2: Forward email to the destination recipient (internal\organization recipient)

PowerShell command syntax

Example
Forward Email to External Recipient & save local copy  import from CSV File Scenario 1

4.4 – Forward Email to External Recipient & save local copy | import from CSV File |Scenario 2

Step 1: Enable to option of DeliverToMailboxAndForward

Example
Forward Email to External Recipient & save local copy  import from CSV File Scenario 2

6. Download PowerShell menu script

For your convenience, I have “Wrapped” all the PowerShell commands that were reviewed in the article,
in a “Menu Based” PowerShell Script.

You are welcome to download the PowerShell script and use it.
Download -o365info PowerShell Script

Manage Forward Mail by using PowerShell | Office 365

Getting started with Office 365 PowerShell

PowerShell Naming Conventions & general information
Get more information about the Naming Conventions that are used in the PowerShell articles – Help and additional information – o365info.com PowerShell articles
Creating a remote PowerShell session to Exchange Online 
To get more information about the required remote PowerShell commands that you need to use for connecting to Exchange Online, read the following article:
Connect to Exchange Online by using Remote PowerShell
Creating a remote PowerShell session to Azure Active Directory
To get more information about the required software component + the remote PowerShell commands that you need to use for connecting Azure Active Directory, read the following article: Part 2: Connect to Office 365 by using Remote PowerShell
Basic introduction to PowerShell in Office 365 based environment
If you are new in the PowerShell world, you can read more information about how to start working with PowerShell in Office 365 based environment in the following article series:  Getting started with Office 365 PowerShell – Part 1, Part 2, Part 3 and Part 4.
Running and using o365info PowerShell scripts
In case that you need more information about how to use the o365info PowerShell scripts that I add to the PowerShell articles, you can read the article – How to run and use o365info PowerShell menu script

PowerShell command syntax – Office 365 | Article series index

Now it’s Your Turn!
It is important for us to know your opinion on this article


Print Friendly, PDF & Email

Related Post

Please rate this

Eyal Doron on EmailEyal Doron on FacebookEyal Doron on GoogleEyal Doron on LinkedinEyal Doron on PinterestEyal Doron on RssEyal Doron on TwitterEyal Doron on WordpressEyal Doron on Youtube
Eyal Doron
Share your knowledge.
It’s a way to achieve immortality.
Dalai Lama

16 Responses to “Manage Forward Mail by using PowerShell | Office 365”

  1. Great article which makes things easy.
    But what is the difference between -ForwardingAddress and -ForwardingSmtpAddress ???

  2. -ForwardingAddress (internal; within organtization), -ForwardingSmtpAddress (external; forward to an email address outside of your organization)

  3. Forward Email to internal Recipient & save local copy (Default)
    Is not the default setting in my office365 config.
    The default is Forward Email to internal Recipient & DONT save local copy
    So the command will be Set-Mailbox -Identity -ForwardingAddress -DeliverToMailboxAndForward $true

  4. “Forward Email to External Recipient & DONT save local copy” => Does this really work? In our case we failed with tests using ForwardingsmtpAddress and what I could read in other discussions our experience was confirmed.

  5. Thanks to the comments above this is the command that I found to work for “Forwarding Email to External Recipient & save local copy | import from CSV File |Scenario 2”:

    Import-CSV “C:\Temp\Users.csv” | % { $_.Condition = [bool]($_.Condition -as [int]); $_ } | ForEach {Set-Mailbox -Identity $_.mailbox -ForwardingSmtpAddress $_.forwardto -Delivertomailboxandforward $TRUE}

  6. Can someone help me with a script to Forward Email to External Recipient & DONT SAVE local copy | import from CSV File

  7. How come -ForwardingSMTPAddress should be used to forward to external email addresses, but the script in section 4.4 “Forward Email to External Recipient & save local copy | import from CSV File” uses -ForwardingAddress

    Import-CSV “C:\Temp\Users.csv” | % { $_.Condition = [bool]($_.Condition -as [int]); $_ } | ForEach {Set-Mailbox -Identity $_.mailbox -ForwardingAddress $_.forwardto -Delivertomailboxandforward $_.Condition}

    Is this just an error in the script? Or is there a reason for this?

  8. Thank you so much, I used “2.2 – Find all users with Forwarding Address is set to Internal Recipient” to find an old mailbox that was causing problems for us! Very nice resource you have with this page.

  9. Oh my goodness! Amazing article dude! Many thanks, However I am going through issues with your RSS.
    I don’t understand why I cannot join it. Is there anybody else getting identical RSS problems?
    Anyone that knows the solution will you kindly respond? Thanx!!

  10. Danny Nguyen Reply

    Great Article. Is there a way to turn on forwarding for a mailbox and it will stop forwarding after 60 days?

  11. I actually adore your post. I read your site pretty regularly and you are always coming out with some
    great items. I shared this on my FB and my followers only loved it.
    Keep up the good work!

Leave a Reply

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