How to Backup and Migrate Outlook Rules With Export-InboxRule via EWS
🔍 WiseChecker

How to Backup and Migrate Outlook Rules With Export-InboxRule via EWS

You have a set of Outlook rules that process incoming email, move messages to folders, or forward items to your team. When you move to a new mailbox or a different Exchange environment, those rules do not transfer automatically. Manually recreating dozens of rules is slow and error prone.

The Export-InboxRule cmdlet in Exchange Management Shell reads rules directly from the server using Exchange Web Services (EWS). It exports each rule to a CSV file, which you can then import into another mailbox with Import-InboxRule.

This article explains how to back up your Outlook server-side rules with Export-InboxRule, migrate them to a new mailbox, and handle common errors during the process.

Key Takeaways: Export and Import Outlook Rules via Exchange PowerShell

  • Export-InboxRule -Mailbox user@domain.com | Export-CSV rules.csv: Exports all server-side rules from the specified mailbox to a CSV file for backup or migration.
  • Import-InboxRule -Mailbox newuser@domain.com -CSVData (Get-Content rules.csv -Encoding Byte): Imports the saved rules into the target mailbox, recreating each rule with its original conditions and actions.
  • Get-InboxRule -Mailbox user@domain.com: Lists all existing rules in a mailbox so you can verify the export or check for conflicts before importing.

ADVERTISEMENT

How Exchange Server-Side Rules Work With EWS

Outlook rules can be client-side or server-side. Client-side rules run only when Outlook is open. Server-side rules run on the Exchange server regardless of whether Outlook is running. Exchange Web Services (EWS) is the API that Exchange PowerShell cmdlets like Export-InboxRule use to read and write these server-side rules.

The Export-InboxRule cmdlet connects to the Exchange server via EWS and retrieves the rule collection from the mailbox. It does not depend on Outlook being installed or running on the machine where you execute the command. The cmdlet outputs a set of rule objects that you can pipe to Export-CSV to create a portable backup file.

The Import-InboxRule cmdlet reads the CSV file and creates rules on the target mailbox using the same EWS endpoints. The target mailbox must be on an Exchange server that supports EWS. Exchange Online and Exchange Server 2013 and later support these cmdlets.

Prerequisites

Before you run Export-InboxRule or Import-InboxRule, verify these requirements:

  • Exchange Management Shell is installed. For Exchange Online, install the Exchange Online PowerShell V2 module.
  • You have the Mail Recipients role or equivalent permissions on both source and target mailboxes.
  • The target mailbox must exist and be accessible from the Exchange server or Exchange Online.
  • Both mailboxes must be in the same Exchange organization or in Exchange Online. Cross-tenant migration requires additional steps.
  • Rules that use conditions or actions not supported on the target server will fail to import.

Steps to Backup and Migrate Outlook Rules

Follow the steps below to export rules from a source mailbox and import them into a target mailbox. All commands run in Exchange Management Shell or Exchange Online PowerShell.

  1. Open Exchange Management Shell
    On a machine with Exchange Management Tools, click Start and type Exchange Management Shell. Right-click the result and select Run as Administrator. For Exchange Online, open Windows PowerShell and run Connect-ExchangeOnline with your admin credentials.
  2. Verify existing rules on the source mailbox
    Run Get-InboxRule -Mailbox source@contoso.com | Format-Table Name,Priority. This lists all server-side rules. Note the names and the total count so you can confirm the export captured everything.
  3. Export rules to a CSV file
    Run Export-InboxRule -Mailbox source@contoso.com | Export-CSV -Path “C:\Backup\OutlookRules.csv” -NoTypeInformation. The -NoTypeInformation parameter removes the header line that marks the object type. The file is saved to the specified path.
  4. Open the CSV file to inspect the rules
    Open the CSV file in Notepad or Excel. Each row is one rule. Columns include Name, Description, Enabled, Priority, From, SentTo, SubjectContains, MoveToFolder, and others. Verify that the rules you expect appear in the file. If you see errors about unsupported conditions, skip or remove those rows before importing.
  5. Import rules to the target mailbox
    Run Import-InboxRule -Mailbox target@contoso.com -CSVData (Get-Content “C:\Backup\OutlookRules.csv” -Encoding Byte). The -CSVData parameter expects the file content as a byte array. The -Encoding Byte argument ensures the file is read correctly. This command creates the rules on the target mailbox.
  6. Verify the imported rules
    Run Get-InboxRule -Mailbox target@contoso.com | Format-Table Name,Enabled,Priority. Compare the list with the source mailbox list. All rules should appear with the same names and priorities.
  7. Test a rule in the target mailbox
    Send a test email from an external account that matches one of the imported rule conditions. For example, if a rule moves messages from a specific sender to a folder, check that the email appears in the correct folder within a few minutes.

ADVERTISEMENT

Common Import Failures and How to Handle Them

Importing rules from one mailbox to another can fail for several reasons. Below are the most frequent issues and their fixes.

Rule uses a condition or action not supported on the target

Some rule conditions, such as forms or message classifications, may not exist on the target server. Open the CSV file in Excel. Delete the entire row for any rule that uses unsupported conditions. Save the file and run the import again.

Target mailbox has the maximum number of rules already

Exchange Online allows up to 256 rules per mailbox. Exchange Server 2016 and 2019 allow up to 256 rules. If the target mailbox already has 256 rules, the import fails. Run Get-InboxRule -Mailbox target@contoso.com | Measure-Object to count existing rules. Delete unnecessary rules from the target before importing.

MoveToFolder action references a folder that does not exist

If a rule moves messages to a folder named “Project X” but that folder does not exist in the target mailbox, the rule is created but the action fails silently. Create the missing folders in the target mailbox before importing the rules. Alternatively, edit the CSV file and change the folder name to an existing folder.

Import fails with access denied error

The account running Import-InboxRule must have Full Access permission on the target mailbox. If you get an access denied error, add the Full Access permission with Add-MailboxPermission -Identity target@contoso.com -User admin@contoso.com -AccessRights FullAccess. Then run the import again.

Export-InboxRule vs Manual Rule Recreation: Key Differences

Item Export-InboxRule via EWS Manual Rule Recreation in Outlook
Time required for 20 rules Less than 5 minutes 30 to 60 minutes
Error risk Low if CSV is inspected before import High due to typos and missing conditions
Requires Outlook installation No Yes
Handles all server-side conditions Yes, exports all supported conditions Yes, but each rule must be recreated from scratch
Supports bulk migration Yes, one CSV file for all rules No, each rule is created individually
Works across Exchange Online tenants No, requires same tenant or on-premises to on-premises Yes, but manual

Export-InboxRule is the faster and more accurate method when both mailboxes are in the same Exchange organization or tenant. Manual recreation is the fallback when cross-tenant restrictions apply.

You can now back up your Outlook server-side rules to a CSV file and migrate them to a new mailbox using Export-InboxRule and Import-InboxRule. The entire process takes a few minutes and preserves rule names, conditions, and actions exactly as they were on the source. For regular maintenance, run Export-InboxRule monthly and store the CSV file in a secure location. If you need to audit rules across many mailboxes, combine Get-InboxRule with a script that outputs the rule count and last modified date for each mailbox.

ADVERTISEMENT