Solved

Globally remove an inbox rule with Powershell

Posted on 2010-08-17
5
2,349 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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Utilizing an array to gracefully append to a list of EmailAddresses
Learn to move / copy / export exchange contacts to iPhone without using any software. Also see the issues in configuration of exchange with iPhone to migrate contacts.
This video discusses moving either the default database or any database to a new volume.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

757 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

22 Experts available now in Live!

Get 1:1 Help Now