Create Inbox Rules in PowerShell

Let’s say you want to create in Inbox Rule and you don’t want to (or can’t) use Outlook to do it. Who cares why, right? You just don’t.

$ReasonsWhy = “Not Relevant”

You can use the New-InboxRule to move, copy, delete, forward, classify…whatever…newly received messages, just like you can if you created the rule through Outlook’s wizard. You can’t do quite everything in PowerShell that can be done via the GUI. For example, you can’t permanently delete the message, bypassing the Deleted Items folder and sending it directly to the dumpster. But you can delete it and mark it as “read” which is almost as good.

Open PowerShell and connect to your Exchange system (or open the Exchange Management Shell), and run New-InboxRule with all of the parameters you want from the long list you can find here. These are some of the options you are most likely to want:

Parameter More info
Mailbox The name, alias, DN, etc., of the mailbox in which you want to create the rule.
Name The name of the Inbox Rule.
SubjectContainsWords Words to look for in the message subject.
BodyContainsWords Words to look for in the message body.
SubjectOrBodyContainsWords Words to look for in both the message subject and body.
From The sender’s email address.
DeleteMessage $True or $False.
MoveToFolder Move the message to this folder.
StopProcessingRules $True or $False.

New-InboxRule example

Leave a Reply

Your email address will not be published. Required fields are marked *