đź”§ New: User Management Graph PowerShell Toolkit

Simplify user tasks like bulk creation, updates, password resets, deletions, license checks & more — all from one place.

🚀 Launch Toolkit

Get-TransportRule: Retrieve Mail Flow Rules in Exchange Online

Microsoft Exchange Online remains the preferred choice for many administrators when it comes to managing mail flow rules, even as Microsoft Graph PowerShell continues to evolve. In this article, we'll explore the Get-TransportRule cmdlet, which helps you retrieve and manage mail flow (transport) rules in your organization.


i) Prerequisites

Before using Get-TransportRule, ensure you’ve installed and connected to Exchange Online PowerShell.

Install Exchange Online Management Module:

Install-Module -Name ExchangeOnlineManagement

Connect to Exchange Online:

Connect-ExchangeOnline -UserPrincipalName admin@yourdomain.com

ii) Cmdlet Syntax

Get-TransportRule

You can optionally use:

Get-TransportRule [-Identity ] [-Filter ]

⚠️ Note: Only limited properties are supported in the -Filter parameter (see usage example below).


iii) Usage Examples

  1. List All Mail Flow Rules
  2. Get-TransportRule

    Displays all mail flow rules configured in your Exchange Online environment.

  3. Fetch Only Enabled Rules
  4. Get-TransportRule | Where-Object {$_.State -eq "Enabled"}

    Filters rules client-side based on their current state.

  5. Filter by Description Using -Filter
  6. Get-TransportRule -Filter {Description -like "*external*"}

    This retrieves rules that mention the word “external” in the rule’s conditions, actions or exception values.


iv)Cmdlet Tips

  • Only the rule’s “conditions, actions and exception” values are valid for use with -Filter. This should be passed to -Filter using “Description” parameter.
  • Use Where-Object when filtering by other properties like Priority, Mode, State, etc.
  • Combine Get-TransportRule with Select-Object for customized views:
  • Get-TransportRule | Select-Object Name, Priority, State

v) Possible Errors & Solutions

Error Cause Solution
The search filter is invalid. -Filter supports only Description parameter which accepts only the rule’s conditions, actions and exception values. Use Where-Object for advanced filtering: Get-TransportRule | Where-Object {$_.State -eq "Enabled"}
The term 'Get-TransportRule' is not recognized Exchange module not installed or session not connected. Run: Install-Module ExchangeOnlineManagement Connect-ExchangeOnline
Access Denied User lacks required permissions. Ensure your account has the Mail Flow role in Exchange admin center.

vi) Conclusion

The Get-TransportRule cmdlet is a powerful tool for listing and filtering mail flow rules (transport rules) in Exchange Online. Whether you're auditing your ruleset, troubleshooting message delivery, or optimizing mail flow, this cmdlet provides vital visibility.

While Graph PowerShell is a promising modern interface, most admins continue to rely on Exchange Online PowerShell for mail flow rule management due to its completeness and stability.


Graph PowerShell Explorer Widget

20 Graph PowerShell cmdlets with easily accessible "working" examples.


Permission Required

Example:


                


                


                

© m365corner.com. All Rights Reserved. Design by HTML Codex