How to Master Automatic Email Forwarding in Exchange Online with PowerShell
Table of Contents
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.
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
- Always verify your mail flow rules and spam filtering settings when configuring external forwarding in Exchange Online.
- Use PowerShell’s flexibility to set up forwarding in bulk for multiple mailboxes.
- Remember to disable forwarding when it’s no longer needed to maintain mailbox organization.