Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Globally remove an inbox rule with Powershell

Posted on 2010-08-17
5
Medium Priority
?
2,801 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
[X]
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
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 500 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 500 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

New style of hardware planning for Microsoft Exchange server.
I don't pretend to be an expert at this, but I have found a few things that are useful. I hope that sharing them here will help others, so they will not have to face some rather hard choices. Since I felt this to be a topic of enough importance and…
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…
Suggested Courses

670 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