Microsoft Office 365Powershell

How to Master Automatic Email Forwarding in Exchange Online with PowerShell

Email forwarding is a powerful tool for streamlining workflows and ensuring messages reach the right people. In Exchange Online, PowerShell offers administrators granular control over forwarding rules. This guide will walk you through the process and provide best practices for configuring Exchange Online email forwarding.

Prerequisites

  • Exchange Online PowerShell: This is typically accessible through the Exchange Management Shell.
  • Administrative Permissions: You’ll need the necessary permissions within your Exchange Online organization to modify mailbox configurations.

Connecting to Exchange Online

2: Enter your Exchange Online administrator credentials when prompted.

Connect-ExchangeOnline

Understanding the 'Set-Mailbox' Cmdlet

The Set-Mailbox cmdlet is your key tool. Here’s a breakdown of the essential parameters:

  • Identity: The email address of the mailbox where you want to enable forwarding (e.g., “jane.doe@company.com”).
  • ForwardingSMTPAddress: The destination email address for forwarded messages. This can be either another internal mailbox or an external address.
  • DeliverToMailboxAndForward: This controls whether a copy of the message is retained in the original mailbox:
    • $true: A copy is kept in the original mailbox, and the message is forwarded.
    • $false: The message is only forwarded, and no copy is kept.
Recommended For You:  How To Remove all Group Membership From Active Directory User Account Except Domain User Group Using PowerShell

Example: Internal Forwarding with Message Retention

Forward all of Jane Doe’s emails to her manager, Mark Smith, while keeping copies in Jane’s mailbox:

Set-Mailbox -Identity jane.doe@company.com -ForwardingSMTPAddress mark.smith@company.com -DeliverToMailboxAndForward $true

Advanced Considerations

  • External Forwarding: Before forwarding to external addresses, consider the following for the best results:

    • Mail Flow Rules (Transport Rules): Ensure these rules permit the forwarding of emails to external domains.
    • Anti-Spam Filters: Adjust your spam filters to avoid mistakenly flagging forwarded messages from your own domain as spam. Could lead to issues when troubleshooting Exchange Online forwarding.
  • Bulk Operations: To apply forwarding to multiple mailboxes at once, employ PowerShell scripts. Here’s a basic example:

Get-Mailbox -ResultSize Unlimited | ForEach-Object { 
    Set-Mailbox -Identity $_.PrimarySmtpAddress -ForwardingSMTPAddress "sharedsupport@company.com" -DeliverToMailboxAndForward $true
}

Disabling Forwarding: Remove forwarding with:

Set-Mailbox -Identity jane.doe@company.com -ForwardingSMTPAddress $null

Summary and Guidelines

Recommended For You:  How To Disable Windows Defender Permanently in Windows 10

Muhammad Faizan

Hi, My name is Muhammad Faizan and i have spent last 15 years working as System Administrator mainly with Microsoft Technologies. I am MCSE, MCTP, MCITP, certified professional. I love scripting and Powershell is the scripting language i am in love with.

Related Articles

Leave a Reply

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

Back to top button