Globally remove an inbox rule with Powershell

Posted on 2010-08-17
Last Modified: 2013-08-06
Is there Powershell command to globally remove an inbox rule for all users in a database in Exchange 2010?  We have over 400 users and I'd prefer to automate this instead of running "remove-inboxrule -mailbox xxx..." command all day long!  Thanks!
Question by:BlazersIT
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Expert Comment

ID: 33456889
have you tried:

Get-Mailbox | Remove-InboxRule -Identity "NameOfTheRule"

Accepted Solution

broeckske earned 125 total points
ID: 33456914
No on second thought I will be more something like this:

Get-Mailbox | ForEach { remove-InboxRule -Name "NameOfTheRule" -Mailbox $_.Name}

Assisted Solution

Razi_Ahmed earned 125 total points
ID: 33457124
try this one

Get-Mailbox | forEach {Remove-Inboxrule –Identity “<Inbox Rule name>”}

Author Closing Comment

ID: 33457605
Thanks.  using -Identity instead of -Name in broeckske's suggestion worked so I am giving Razi credit also.

Expert Comment

ID: 39386307
None of these solutions will work if a mailbox contains rules with  duplicated names. If, for instance, a mailbox has 5 copies of a filter called [SPAM], the solutions above will throw errors and won't remove anything.

To delete duplicates you need to iterate through all of the filters on each mailbox and delete them one by one. The below snippet will generate the powershell commands needed to do this for each mailbox. From  a batch I redirect this output to a file, grep just the Get-InboxRule lines and output it to a temporary .ps1 file which the batch then proceeds to call so it can all be one click and clean.

$users = get-mailbox -resultsize unlimited | foreach-Object {
$this_name =$_.Name
write-Host Get-InboxRule -Mailbox `"$this_name`" `| where `{`$_.Name `-eq `"[SPAM]`"`} `| Remove-InboxRule `-Confirm:`$False `-Force


Featured Post

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Finding original email is quite difficult due to their duplicates. From this article, you will come to know why multiple duplicates of same emails appear and how to delete duplicate emails from Outlook securely and instantly while vital emails remai…
This article describes how to import an Outlook PST file to Office 365 using a third party product to avoid Microsoft's Azure command line tool, saving you time.
The basic steps you have just learned will be implemented in this video. The basic steps are shown to configure an Exchange DAG in a live working Exchange Server Environment and manage the same (Exchange Server 2010 Software is used in a Windows Ser…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question