Get mail flow rules powershell

You can use the following PowerShell commands to get mail flow rules in Exchange Online:

Get all mail flow rules:

Get-TransportRule

This command retrieves all mail flow rules in your organization.

Get specific mail flow rule:

Get-TransportRule -Identity <RuleName>

Replace <RuleName> with the name of the mail flow rule you want to retrieve.

Get mail flow rules with specific conditions:

Get-TransportRule -Filter {Condition -eq "<ConditionName>"}

Replace <ConditionName> with the name of the condition you want to filter by (e.g. "Contains", "HasAttachment", etc.).

Get mail flow rules with specific actions:

Get-TransportRule -Filter {Action -eq "<ActionName>"}

Replace <ActionName> with the name of the action you want to filter by (e.g. "Reject", "Delete", etc.).

Get mail flow rules with specific exceptions:

Get-TransportRule -Filter {Exception -eq "<ExceptionName>"}

Replace <ExceptionName> with the name of the exception you want to filter by (e.g. "Sender", "Recipient", etc.).

You can also use the -ResultSize parameter to limit the number of results returned, for example:

Get-TransportRule -ResultSize 100

This will return the first 100 mail flow rules.

Note: You need to have the necessary permissions and credentials to run these PowerShell commands.