Last updated on Jun 4, 2018
Export Exchange Online Transport Rules
In this post, I will focus on how to export Exchange Online Transport rules using PowerShell.
To get started we first need to establish a connection to Exchange Online or Office 365.
- Connect to Exchange Online PowerShell
1 |
$UserCredential = Get-Credential |
Then
1 2 3 |
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection |
And Finally, We need to import the newly created session.
1 |
Import-PSSession $Session |
Alternatively you can download the following script from TechNet to Connect: https://gallery.technet.microsoft.com/office/Connect-To-Office-365-9b235018
Once we have established a connection to Exchange Online, we can then run the following cmdlets to export the current Transport Rules.
The data is first exported to a variable $file, and then written to an XML file using
Set-Content and then saved to a path specified. In this case its “C:\Export\Rules.Xml”.
1 |
$file = Export-TransportRuleCollection; Set-Content -Path "C:\Export\Rules.xml" -Value $file.FileData -Encoding Byte |
The Exported file will look as follows
The Xml file will look as follow, with the details of the Transport Rule etc.
#ThatLazyAdmin
This is the second time I have come across you in a google search. Will come here for now on first.