PowerShell Genie

Transport rule inventory

Script 2 min read Windows PowerShell 5.1 and PowerShell 7

Documentation: Microsoft Learn

Get-TransportRule returns every rule in the organization and the projection keeps the name with State, Mode, Priority, and Description.

The script

1PS> Get-TransportRule | Select-Object Name,State,Mode,Priority,Description

Script reader

Inspect before you run

Inspection only

Inspect the script below. It does not run in this browser.

Inspection only — no command has run.

    Show reference output
    1 Name State Mode Priority Description
    2 ---- ----- ---- -------- -----------
    3 Block executable files Enabled Enforce 0 Reject executable attachments
    Inspect this example’s structure

    Read the command and its supplied arguments. This example requires real PowerShell or its module; this diagram does not execute it.

    Get-TransportRule | Select-Object Name,State,Mode,Priority,Description
    1. Stage 1Get-TransportRulePositional values or no named parameters
    2. Stage 2Select-ObjectPositional values or no named parameters

      How it works

      Get-TransportRule returns every rule in the organization and the projection keeps the name with State, Mode, Priority, and Description. Priority is the evaluation order, and Mode says whether a rule enforces its action or is only auditing what it would have done.

      Adapting it

      Sort on Priority so the table reads in the order the service evaluates rules, which is how a conflict between two of them becomes obvious.

      Requirements

      ExchangeOnlineManagement module with a Connect-ExchangeOnline session.

      If the result is unexpected

      A transport-rule list does not explain why a message was handled unexpectedly.

      Rule priority, enabled state, conditions and exceptions influence which actions apply.

      1. Inspect the relevant rule in priority order and compare its conditions with the message evidence.

      Validate the result

      The suspected rule's state and conditions account for the observed handling or are ruled out.

      Keep the check reliable

      Retain rule names, priorities and exceptions together in change reviews.

      Primary documentation

      PowerShell objects and pipelines documentation

      Continue
      Genie guideTransport rule inventory

      Get-TransportRule returns every rule in the organization and the projection keeps the name with State, Mode, Priority, and Description.