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:

Mail forwarding to an internal recipient: John and Suzan are recipients who belong to the office 365 domain names: o365info.com

Mail forwarding to External recipient: John wants to forward each mail that he gets to an external email address: [email protected]

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.

4. Export information about forwarding settings

Exoprt informaiton about USER Forwarding rule

Export to CSV file:PowerShell command Example

1

Get-Mailbox-ResultSizeUnlimited|Where-Object{($_.ForwardingsmtpAddress-ne$Null)}|Select-ObjectDisplayName,Alias,PrimarySmtpAddress,ForwardingAddress,ForwardingsmtpAddress,DeliverToMailboxAndForward,RecipientType,RecipientTypeDetails|Export-CSVC:\TEMP\"All Recipents that have USER Forwarding(ForwardingsmtpAddress).CSV"–NoTypeInformation-Encodingutf8

Exoprt informaiton about ADMIN Forwarding rule

;foreach($fwdin$fwds){$fwd|add-member-membertypenoteproperty-name“ContactAddress”-value(get-contact$fwd.ForwardingAddress).WindowsEmailAddress};$fwds|Export-CSVC:\TEMP\"All Recipents that have Admin Forwarding(ForwardingAddress).CSV"–NoTypeInformation-Encodingutf8

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

this is very great and another way to get anonymous email for everyone and your primary email id will remain hidden but you will receive emails on your primary email ID. Its very great and just amazing. make anonymous email

“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.

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

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.