Simplify user tasks like bulk creation, updates, password resets, deletions, license checks & more — all from one place.
🚀 Launch ToolkitIn Microsoft Exchange Online, mail flow rules—also known as transport rules—are essential for controlling and automating how email is processed. These rules allow administrators to apply conditions and actions to messages that pass through the transport pipeline.
While Graph PowerShell continues to evolve, it does not yet support the creation of mail flow rules. For now, you must use Exchange Online PowerShell to manage mail flow at this level.
This article dives into the New-TransportRule cmdlet, illustrating how to create custom rules with real-world examples, practical tips, and troubleshooting guidance.
New-TransportRule -Name [-Comments ] [-Priority ] [-Enabled <$true | $false>] [-SentTo ] [-From ] [-SenderDomainIs ][-RedirectMessageTo ] [-RejectMessageReasonText ][-SetAuditSeverity ][-Other Parameters...]
You must be connected to Exchange Online using:
Connect-ExchangeOnline
New-TransportRule -Name "Redirect CEO Emails" ` -SentTo "samadmin@7xh7fj.onmicrosoft.com" ` -RedirectMessageTo "dexter@7xh7fj.onmicrosoft.com"
This rule redirects all emails sent to the CEO's mailbox to another address, which can be helpful for delegation or monitoring.
New-TransportRule -Name "Block Example.com Emails" ` -SenderDomainIs "example.com" ` -RejectMessageReasonText "Emails from gmail.com are not accepted."
This rule blocks any incoming emails from senders using example.com and returns a rejection notice to the sender.
Error | Cause | Solution |
New-TransportRule is not recognized | Not connected to Exchange Online | Run Connect-ExchangeOnline |
The transport rule name already exists | Duplicate rule name | Use a unique name or modify existing rule |
Invalid parameter | Typo or unsupported combination | Use Get-Help New-TransportRule -Full for guidance |
SenderDomainIs requires a valid domain | Domain not formatted correctly | Use values like "domain.com" without wildcards |
The New-TransportRule cmdlet is a powerful way to manage mail flow policies in Microsoft Exchange Online. Whether you're automating redirection, filtering senders, or enforcing company email policies, this cmdlet has you covered.
As Graph PowerShell matures, we may see support for these configurations in the future—but for now, Exchange PowerShell remains the definitive tool for managing transport rules.
© m365corner.com. All Rights Reserved. Design by HTML Codex