On this article we will learn how to export and import transport rules in our exchange
What Transport rules do?
You can use mail flow rules (also known as transport rules) to identify and take action on messages that flow through your Exchange Online organization. Mail flow rules are similar to the Inbox rules that are available in Outlook and Outlook on the web
This can be useful to :
- Save a backup
- Check previous rules or new rules
- Roll back any changes made on this configuration
Step 1. Connect to Exchange online
Guidance’s of how to install the module can be find here:

Step 2 Export the Actual Rules
Execute the following to export the XML in your machine
$file = Export-TransportRuleCollection
Set-Content -Path "C:\Scripts\Rules.xml" -Value $file.FileData -Encoding Byte
Importing the XML in case of need
Execute the following commands to Import the XML from your machine into Exchange
[Byte[]]$Data = Get-Content -Path "C:\Scripts\Rules.xml" -Encoding Byte -ReadCount 0
Import-TransportRuleCollection -FileData $Data