Solved

Globally remove an inbox rule with Powershell

Posted on 2010-08-17
5
2,404 Views
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!
0
Comment
Question by:BlazersIT
5 Comments
 
LVL 7

Expert Comment

by:broeckske
ID: 33456889
have you tried:

Get-Mailbox | Remove-InboxRule -Identity "NameOfTheRule"
0
 
LVL 7

Accepted Solution

by:
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}
0
 
LVL 6

Assisted Solution

by:Razi_Ahmed
Razi_Ahmed earned 125 total points
ID: 33457124
try this one

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

Author Closing Comment

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

Expert Comment

by:ramtek_us
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
write-Host
}

-Matt
0

Featured Post

Don't lose your head updating email signatures!

Do your end users still have the wrong email signature? Do email signature updates bore you or fill you with a sense of dread? You can make this a whole lot easier on yourself by trusting an Exclaimer email signature management solution. Over 50 million users do...so should you!

Question has a verified solution.

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

This process describes the steps required to Import and Export data from and to .pst files using Exchange 2010. We can use these steps to export data from a user to a .pst file, import data back to the same or a different user, or even import data t…
This article lists the top 5 free OST to PST Converter Tools. These tools save a lot of time for users when they want to convert OST to PST after their exchange server is no longer available or some other critical issue with exchange server or impor…
In this video we show how to create a Shared Mailbox in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: First we need to log into the Exchange Admin Center. Navigate to the Recipients >> Sha…
To show how to generate a certificate request in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.:  First we need to log into the Exchange Admin Center. Navigate to the Servers >> Certificates…

867 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now