Today got a task to import all the transport rules in On-Premise Exchange servers to Office 365. Creating new transport rules in O365 with same condition will work but more than 50 transport rules are in On-Premise Exchange Server and will take long time to create as well as condition may not match properly. So planned to export the existing transport rules in On-Premise Exchange Server using PowerShell Commands and details are as follow:
PS Cmdlet to export the existing transport rules in On-Premise:
$onpremrule = Export-TransportRuleCollection
Set-Content -Path “C:\Rules.xml” -Value $onpremrule.FileData -Encoding Byte
Import will overwrite the existing transport rules in O365, please take a backup of O365 rules before importing On-premises rules to O365.
PS Cmdlet to import the exported transport rules in Office 365:
[Byte[]]$O365 = Get-Content -Path “C:\Rules.xml” -Encoding Byte -ReadCount 0
Import-TransportRuleCollection -FileData $O365
Please share your thoughts by clicking Leave a Comment and if you like the articles in this site, please subscribe to get Email notification when a new article has been published. Thank You.