Export transport rules from Exchange or Exchange Online

After all my work last week creating Exchange transport rules for profanity, audio/video attachments, message encryption and more, I wanted to export the rules just in case they needed to be re-established.  Thanks to TechNet, I found the required PowerShell to export transport rules from Exchange or Exchange Online, which is:

$file = Export-TransportRuleCollection
Set-Content -Path "ExchangeOnlineRules.xml" -Value $file.FileData -Encoding Byte

The resulting XML includes the New-TransportRule commands to re-create the rules if required (or the Import-TransportRuleCollection cmdlet can be used instead).

One thought on “Export transport rules from Exchange or Exchange Online

  1. Funnily enough, i came across this today. Although the export worked from exchange 2010 and dumped the XML it errored when importing to 365. Exporting again from an Exchange 2016 server in the same org worked…..(using the same export command). Odd.

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.