All scripts
Microsoft 365 476
Get-TransportRuleReport
Exports every mail flow rule in the tenant with its conditions, actions and enabled state to a single readable table, so a growing pile of transport rules stays auditable.
Get-TransportRuleReport.ps1
<#
.SYNOPSIS
Reports all Exchange transport (mail flow) rules.
.DESCRIPTION
Exports every transport rule with its priority, enabled state, and a
short summary of its conditions and actions, since a tenant that has
been running a while usually has more mail flow rules than anyone
remembers, some of them contradicting each other.
.EXAMPLE
.\Get-TransportRuleReport.ps1
.NOTES
Requires ExchangeOnlineManagement and an active Connect-ExchangeOnline session.
.AUTHOR
Shehryar Hassan
#>
$rules = Get-TransportRule
$report = $rules | ForEach-Object {
[pscustomobject]@{
Name = $_.Name
Priority = $_.Priority
Enabled = $_.State -eq "Enabled"
Conditions = ($_.Description -split [Environment]::NewLine | Select-Object -First 1)
Mode = $_.Mode
}
}
$report | Sort-Object Priority | Format-Table -AutoSize
Read it before you run it, and test in a safe tenant first.