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).