Lets see in a hybrid in Environment. We got to move the transport Rules from On-Premises Server to Office 365. So that transport rules will still work when mail flow hits the cloud for Mail processing.
Export XML file from On premises Server –
$file = Export-TransportRuleCollection
Set-Content -Path "C:\Scripts\Rules.xml" -Value $file.FileData -Encoding Byte
Connect to Exchange Online PowerShell –
$UserCredential = Get-Credential
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection
Import XML file to Office 365 –
[Byte]$Data = Get-Content -Path "C:\Scripts\Rules.xml" -Encoding Byte -ReadCount 0
Import-TransportRuleCollection -FileData $Data
Note : Import from Exchange 2010 Server is not Supported. Error : It cannot be used with a engine-based XML File is Datacenter Environment.
Thanks for the post, I know it’s quite old… I would like to check with you if this still works in exchange online.
I have a ex2010 hybrid setup with Microsoft 365 environment, I need to export all transport rules and import it in exchange online. Please help.