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.
EXPORT:
Change the path to an existing path.
$file = Export-TransportRuleCollection;
Set-Content -Path "C:\Test\Rules.xml" -Value $file.FileData -Encoding Byte;
IMPORT:
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;
ADDITIONAL INFORMATION:
Jason works as a project specialist at an IT MSP in Pennsylvania, USA. He’s an IT/security professional with 20 years experience.