Exchange Online mail flow

How to export mail flow rules in Exchange Online

Export mail flow rules with Exchange Online PowerShell, read each one in the Exchange admin centre, or run Altivane's Transport Rules report for a workbook that flags rules to review.

By the Published Updated

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.

Choose the method that fits the job
MethodBest fit
PowerShellA CSV of every rule in priority order, and an XML copy of the whole collection.
Admin centreReading 1 rule's conditions and settings, or checking the order the rules run in.
AltivaneRecommended 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.

PowerShell
# Install once, if the module is not already installed.
Install-Module ExchangeOnlineManagement -Scope CurrentUser
PowerShell
$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.

PowerShell
# 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

  1. Open the Exchange admin centre for the correct tenant.
  2. Go to Mail flow > Rules. The rules are listed in the order they are processed, and the rule at the top has Priority 0.
  3. Select a rule by clicking anywhere in its row other than the radio button beside its Status.
  4. Read the conditions and settings in the flyout that opens. The rule's status is Enabled or Disabled.
  5. 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.

Common 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.

Talk to us about Altivane

Questions, or pricing? Get in touch.

Contact us