Managing Inbox Rules in Exchange with PowerShell |

Outlook mailbox rules allow users to configure various conditions for processing incoming e-mail messages in the Inbox folder. You can use Outlook rules to move e-mail from specific senders to target mailbox folders, forward email to another user, and more. Users can create and manage mailbox rules from the Outlook GUI. Exchange administrators can manage rules in user mailboxes through PowerShell. In this article, we will show you how to use PowerShell to create, delete, disable, and modify Outlook inbox rules in Exchange Server and Microsoft 365 (Exchange Online) mailboxes.

Client-Side vs Server-Side Outlook Rules

There are two types of inbox rules that can be configured in Outlook: client-side nd server-side rules.

  • server side Outlook rules are executed on the Exchange Server side when email is received. They always work, no matter whether the user is running the Outlook client (rules created with Outlook Web App are always server-side). The following rules can be applied on the Exchange Server side: Mark an email as important, Move an email to another mailbox folder, Delete a message, Forward an email to another mailbox;
  • client side The rules are applied only when the Outlook client starts. Examples of rules include moving an e-mail to a PST file, marking an email as read (how to check if an Exchange user has read an email), displaying an alert, or playing a sound. You cannot manage these rules through PowerShell. These rules have ‘client-only’ status in the Outlook interface.

List of Server-Side and Client-Side Rules in Outlook

A warning is displayed when creating a new rule in Outlook to be processed on the client:

This rule is a client-only rule, and will process only when Outlook is running.

This rule is a client-only rule, and will only process when Outlook is running.

Get-InboxRule: How to list user inbox rules in Exchange mailbox?

Let’s try to look at the inbox rules in the user’s mailbox. Connect to your Exchange environment by using PowerShell.

The following cmdlets are used to manage mailbox rules in Exchange:

  • Get-InboxRule
  • New-InboxRule
  • Enable-InboxRule
  • Disable-InboxRule
  • Set-InboxRule
  • Remove-InboxRule

To view a list of rules in an Exchange mailbox, run the following PowerShell command

Get-InboxRule –Mailbox john.doe

Managing Outlook Mailbox Rules Through PowerShell

As you can see, for each rule the name, status (enabled: true/false), priority, and rule identity are displayed.

You can view detailed information about a specific inbox rule by specifying its name:

Get-InboxRule -Mailbox john.doe -Identity "HelpDesk"| fl

Usually, you can understand the content of a rule from its description:

Get-InboxRule -Mailbox john.doe -Identity "HelpDesk "| Select Name, Description | fl

Get-inbox rule for Exchange mailbox

The Get-InboxRule cmdlet does not list Outlook client-side rules.

Outlook inbox may contain hidden server-side rules. These rules are not visible in the Outlook client or OWA. You can list hidden mailbox rules by using -Hidden Include Parameters:

Get-InboxRule -Mailbox john.doe -IncludeHidden

You can use PowerShell to find specific rules in a user’s mailbox. For example, you need to find all the rules for deleting e-mails:

Get-InboxRule -Mailbox john.doe | ?{ $_.DeleteMessage }

Also, there may be a scenario when information security department asks you to find all automatic email forwarding rules in all user mailboxes in your company:

foreach ($i in (Get-Mailbox -ResultSize unlimited)) { Get-InboxRule -Mailbox $i.DistinguishedName | where {$_.ForwardTo} | fl MailboxOwnerID,Name,ForwardTo >> C:\PS\All_Mailbox_Forward_Rules.txt }

The resulting text file will contain a list of mailboxes, the names of the forwarding rules, and the recipients to whom messages will be forwarded.

Create an Inbox Rule in Outlook with PowerShell

You can create a new rule for Outlook inbox by using New-InboxRule Exchange cmdlet. For example, you want to forward all e-mail containing certain keywords in the subject to another user. Run this command:

New-InboxRule -Name ZenossAlerttoHelpdesk -Mailbox NYadmin -SubjectContainsWords "Zenoss HW Alert" -ForwardTo "Helpdesk"

new-inboxrule powershell

In some cases, when you use PowerShell to create rules in a mailbox, all Outlook client-side rules are disabled. In this case, a warning is displayed:

New-InboxRule: Using Outlook Web App or Windows PowerShell to modify your rules will delete any rules that were previously turned off using Outlook. If you want to preserve the rules you turned off using Outlook, select "No" and use Outlook to edit your  rules. Are you sure you want to proceed.

The following rule will set the red category and high importance for all e-mail from [email protected] with the keyword “Annual Meeting” in the subject:

New-InboxRule -Mailbox john.doe –name SecretaryRule -From [email protected] –SubjectContainsWords “Annual meeting" -ApplyCategory "Red Category" -MarkImportance "High" -StopProcessingRules $true

An example of a rule that moves all messages received before 01/01/2023 to the archive folder:

New-InboxRule -Name "Move to Archive" -Mailbox john.doe -MoveToFolder "john.doe:\Inbox\Archive" -ReceivedBeforeDate "01.01.2023"

View Inbox Rules in Outlook Web

Forward all e-mail for a specified time period:

New-InboxRule -name ForwardTo -mailbox john.doe -ReceivedAfterDate 12/12/2022 -ReceivedBeforeDate 01/01/2023 -ForwardTo [email protected]

You can create a rule for all users in a specific Organizational Unit (OU) in AD that automatically moves email with the subject “Casino” to the Junk Email folder.

$mbxs = Get-mailbox -organizationalUnit Managers
$mbxs | % { }
$mbxs | % { New-inboxrule -Name SpamMail -mailbox $_.alias -subjectcontainswords "[casino]" -movetofolder “$($_.alias):\Junk Email” }

To see a list of all available properties, conditions, and actions used in Exchange rules:

Get-InboxRule -Mailbox john.doe | get-member

Type Name: Microsoft.Exchange.Management.RecipientTasks.InboxRule


If you want to create an inbox rule on a shared Exchange mailbox, make sure that you have been assigned the ‘Organization Management’ role or have been granted ‘Full Access’ permission. You can manage mailbox permissions by using PowerShell:

Add-MailboxPermission -Identity itdept -User john.doe -AccessRights FullAccess -AutoMapping:$false -InheritanceType All

To replace the Outlook rule, use Set-InboxRule Cmdlet:

Set-InboxRule -Mailbox john.doe –identity SecretaryRule -FromAddressContainsWords {}

tip, Rules limit the size of Microsoft Exchange mailboxes. By default, 64 KB is allocated for inbox rules in Exchange 2019/2016/2013/2010. An error occurs when the size of the rules is exceeded:

One or more rules could not be uploaded to Exchange server and have been deactivated. This could be because some of the parameters are not supported or there is insufficient space to store all your rules.

Only the enabled rules are taken into account. A mailbox can have an unlimited number of disabled rules. You can change the Rules Quota to 256 KB using this command:

Set-Mailbox -identity john.doe -RulesQuota 256Kb

How to disable and remove Outlook inbox rule?

To disable a specific Outlook inbox rule, use the command:

Disable-Inboxrule –Mailbox john.doe -Identity “SecretaryRule”

Its status (Enabled) will be changed to False and will not be applied to incoming e-mail messages.

To completely remove the inbox rule, run this command:

Remove-Inboxrule –Mailbox john.doe -Identity SecretaryRule

The command will ask you to confirm it, and all you have to do is press Y, To remove all rules from a user’s mailbox, run the following:

Get-inboxrule -mailbox john.doe | Disable-Inboxrule

You can delete all mailbox rules from Outlook by running this with an additional parameter:

Outlook.exe /cleanrules

This will delete all client-side rules and server rules for all mailboxes configured in your Outlook profile.

If you get an error when you try to enable or disable auto-reply (Out of Office) in your mailbox:

The Out Of Office Rules cannot be displayed. The client operation failed.


System resources are critically low.

Out of Office rules cannot be displayed.  client operation failed

The cause of the problem are corrupted rules in the mailbox. Use PowerShell to delete all rules (including hidden ones) in a mailbox.

Get-InboxRule -Mailbox john.doe -IncludeHidden | Remove-InboxRule

Leave a Comment