Exchange Transport Rules - Export and Import to EXO

Today I attempted to export transport rules from an Exchnage Server (2013) and Import these into Exchnage Online using the script:


#Set-ExecutionPolicy

Set-ExecutionPolicy Unrestricted -Scope Process -Force

#Set PowerShell to use TLS 1.2

[Net.ServicePointManager]::SecurityProtocol = "tls12"

#Check and create directory

IF (Test-Path C:\Temp\TransportRules) {Write-Host "directory exists"} ELSE {New-Item -path C:\Temp\ -Name TransportRules -ItemType Directory}

##### EOP ######

#Load the Exchange Management Shell Module

  $CallEMS = ". '$env:ExchangeInstallPath\bin\RemoteExchange.ps1'; Connect-ExchangeServer -auto -ClientApplication:ManagementShell "

      Invoke-Expression $CallEMS

#Export Transport Rules

$file = Export-TransportRuleCollection

Set-Content -Path "C:\Temp\TransportRules\Rules.xml" -Value $file.FileData -Encoding Byte

 

##### EXOL ######

#Install Modules

Install-Module -Name "ExchangeOnlineManagement" -Force -AllowClobber

#Import Module

Import-Module -Name "ExchangeOnlineManagement"

#Connect to Exchange Online

Connect-ExchangeOnline -ShowProgress $true

#Import Transport Rules

[Byte[]]$Data = Get-Content -Path "C:\Temp\TransportRules\Rules.xml" -Encoding Byte -ReadCount 0

Import-TransportRuleCollection -FileData $Data -force

 

The Import-TransportRuleCollection is detailed here which shows it supports EXO - https://docs.microsoft.com/en-us/powershell/module/exchange/import-transportrulecollection?view=exchange-ps

Unfortunatley it appears MS have disabled the ability to import Transport Rules:


After further investigation you can contact MS and ask them to enable this functionality.


Comments