We were migrating one of our Client from one Tenant to Other. They want to move the transport rules on Exchange online in the first tenant to the second Tenant.
Issue is that second tenant also has some transport rules, so transport rules need to be merged instead of move.
Here are the Steps that needs to be followed to achieve this:
On first tenant
-
Connect to Exchange online thru PowerShell using (Exchange Online Management Module)
Connect-ExchangeOnline
-
Execute below commands to export all transport rules in xml file.
$file = Export-TransportRuleCollection
Set-Content -Path “c:\temp\TransportRulesFirstTenant.xml” -Value $file.FileData -Encoding Byte
-
Disconnect from Exchange online
Disconnect-ExchangeOnline
On Second Tenant follow the Same steps
-
Connect to Exchange online thru PowerShell using (Exchange Online Management Module)
Connect-ExchangeOnline
-
Execute below commands to export all transport rules in xml file.
$file = Export-TransportRuleCollection
Set-Content -Path “c:\temp\TransportRulesSecondTenant.xml” -Value $file.FileData -Encoding Byte
-
Disconnect from Exchange online
Disconnect-ExchangeOnline
Now use any popular XML editor and edit the XML file for the second tenant.
(I have used Notepad++)
Open the XML file of first Tenant as well in the Notepad++ , Use Cntrl + H and replace -Mode Enforce to -Enabled $False -Mode Enforce
Please check carefully that rule that are already disabled are not duplicated with -Enabled $False -Enabled $False -Mode Enforce, if that is the case then replace -Enabled $False -Enabled $False -Mode Enforce with -Enabled $False -Mode Enforce
This will ensure all the rules are set to Disable at first when importing to the second tenant.
Now copy all the rules from it (note open/close <rule </rule>). Paste it in the second Tenant file after the last rule and before </rules>
Ones this is completed, We need to perform the XML import operation on the second Tenant.
Note: This will cause existing rules to delete first and then all rules are imported.
I had used the third trial tenant to import these rules before importing it in prod tenant so that if any errors are there it can be fixed and there is no production impact during the import process.
Below is the import process that needs to be followed:
#############################################################
Connect-ExchangeOnline
[Byte[]]$Data = Get-Content -Path “c:\temp\TransportRulesCombinedTenant.xml” -Encoding Byte -ReadCount 0
Import-TransportRuleCollection -FileData $Data
Disconnect-ExchangeOnline
#############################################################
You can see that now all rules are merged, second tenant rules (enabled) followed by first tenant rules (disabled).
You can also refer Microsoft link if you want to know about other move settings from one tenant to another.
For merging you must use the above approach else rules will be overwritten from first tenant to second and will not be merged.
Thanks for reading………
Tech Wizard