Export/Import Exchange Online Transport Rules via PowerShell

Use this PowerShell to export Exchange Online transport rules via PowerShell.

Connect to Exchange Online via PowerShell like normal.

The import will prompt you, letting you know it’ll overwrite all existing rules.


Change the path to an existing path.

$file = Export-TransportRuleCollection;
Set-Content -Path "C:\Test\Rules.xml" -Value $file.FileData -Encoding Byte;


Change the path to the same path you used above.

[Byte[]]$Data = Get-Content -Path "C:\Test\Rules.xml" -Encoding Byte -ReadCount 0;
Import-TransportRuleCollection -FileData $Data;


IMPORT: https://docs.microsoft.com/en-us/powershell/module/exchange/import-transportrulecollection?view=exchange-ps

EXPORT: https://docs.microsoft.com/en-us/powershell/module/exchange/export-transportrulecollection?view=exchange-ps

Leave a Reply

Your email address will not be published. Required fields are marked *