To export mail flow rules in Exchange Online, read them with Get-TransportRule and write the settings to a CSV. The Description column summarises each rule's conditions, exceptions and actions in 1 cell, and the file is a snapshot: Exchange keeps no history of rule changes. For a complete copy of every rule, export the collection as XML with Export-TransportRuleCollection.
| Method | Best fit |
|---|---|
| PowerShell | A CSV of every rule in priority order, and an XML copy of the whole collection. |
| Admin centre | Reading 1 rule's conditions and settings, or checking the order the rules run in. |
| Altivane | Recommended for regular rule reviews, with the rules to review flagged in a workbook. |
Before you start
Use an account in the Organization Management role group, which Microsoft lists for mail flow rules. Members of the View-Only Management role group can view the configuration of those features.
The export is a snapshot of the rules, enabled and disabled alike. It covers mail flow rules only. Inbox rules, which belong to a mailbox, are separate and not included. The examples read and export and change nothing.
Option 1
Export mail flow rules with PowerShell
Install the module once, then connect and export every rule in priority order.
# Install once, if the module is not already installed.
Install-Module ExchangeOnlineManagement -Scope CurrentUser$ErrorActionPreference = 'Stop'
Connect-ExchangeOnline
try {
$rules = @(Get-TransportRule -ResultSize Unlimited)
if ($rules.Count -eq 0) {
Write-Output 'No mail flow rules were found.'
} else {
$description = @{
Name = 'Description'
Expression = { ($_.Description -replace '\s+', ' ').Trim() }
}
$rules | Sort-Object Priority |
Select-Object Priority, Name, State, Mode, $description, StopRuleProcessing,
ActivationDate, ExpiryDate, Comments |
Export-Csv -Path './mail-flow-rules.csv' -NoTypeInformation -Encoding utf8
Write-Output "$($rules.Count) mail flow rules exported."
}
} finally {
Disconnect-ExchangeOnline -Confirm:$false
}The CSV has 1 row for each rule, with priority 0 first. Get-TransportRule returns 1000 rules unless told otherwise, so the script passes -ResultSize Unlimited; add -State Enabled to keep only enabled rules. ActivationDate and ExpiryDate bound the period the rule is active: after the expiry date the rule stays Enabled but is not processed.
Export a complete copy as XML
Run this while connected. It writes every rule's full definition to a file in the current folder.
# Run while connected to Exchange Online.
$file = Export-TransportRuleCollection
[System.IO.File]::WriteAllBytes((Join-Path $PWD 'mail-flow-rules.xml'), $file.FileData)Microsoft's manual import steps read this file. They remove every existing rule before importing, so read them in full before restoring anything.
Option 2
Read mail flow rules in the admin centre
- Open the Exchange admin centre for the correct tenant.
- Go to Mail flow > Rules. The rules are listed in the order they are processed, and the rule at the top has Priority 0.
- Select a rule by clicking anywhere in its row other than the radio button beside its Status.
- Read the conditions and settings in the flyout that opens. The rule's status is Enabled or Disabled.
- Close the flyout without choosing Edit rule conditions or Edit rule settings, and leave the Enable or disable rule toggle alone, so nothing changes.
This suits reading 1 rule or checking the order. For a file to keep, use the PowerShell export: the Exchange transport rule report under Reports > Mail flow exports the messages the rules affected, not the rules.
Option 3 ยท Recommended for regular rule reviews
Run Altivane's Transport Rules report
- Open Altivane and choose the tenant.
- Run the Transport Rules report for Exchange Online.
- Open the Excel workbook the run wrote.
- Read its table: Priority, Name, State, Mode, Description, Stops processing, Starts, Ends, Comments, Last changed, Status and Reason.
The table lists every rule in priority order with Exchange's own description of it, and rates the rules that are enabled and enforced. A rule that bypasses spam filtering is marked Warning. A rule is marked Review when it copies or redirects mail to an address outside your accepted domains, tells Defender to skip Safe Links or Safe Attachments, or has passed its end date, and the Reason column says which. Disabled rules and rules only being tested stay at OK.
Contact usCommon questions
Why are a rule's conditions and actions in 1 column?
Exchange returns a Description property that summarises the conditions, exceptions and actions with their values. For every setting of every rule, use the XML export, or pipe 1 rule to Format-List.
Can I see what a rule looked like before it changed?
No. Microsoft says the history of rule changes is not kept and rules cannot be reverted to a previous state, so dated exports are the only record. Altivane's Last changed column shows when a rule changed, not what changed.
Do mail flow rules count as mailbox forwarding?
No. A rule can redirect a message or add recipients as it passes through the organisation, whereas a mailbox's own forwarding is set on the mailbox. To review the mailbox side, see how to find mailbox forwarding in Exchange Online.
Microsoft references
Technical references checked on 5 October 2026. The example scripts have been reviewed and syntax checked; they have not been run against a live tenant.