简体   繁体   中英

Remove rules with command Remove-InboxRule

I would like to remove by filtering " Filter * " a massive rules. Have this command but can't run correctly

Remove-InboxRule -Mailbox user@domain.com -Identity 'Filter *' -Confirm:$false

Is it possible?

If I'm reading this correctly you want to remove all rules from a mailbox. The identity parameter doesn't allow for wildcards, so in that regard there is no filtering capability. -Identity does support pipeline input, so you can however pipe the results of Get-InboxRule:

Get-Mailbox user@domain.com | Get-InboxRule | Remove-InboxRule -WhatIf

OR:

Get-InboxRule -Mailbox user@domain.com | Remove-InboxRule -WhatIf

You can insert additional filtering via a Where clause between Get-InboxRule and Remove-InboxRule:

Example:

Get-Mailbox user@domain.com | Get-InboxRule | Where{$_.MoveToFolder -eq "Junk E-Mail"} | Remove-InboxRule -WhatIf

I have to caution you that any rules that had been un-checked in Outlook will get deleted any time you change rules from the shell I've worked on this a lot in the past and the only API that seems not to have this issue is the Outlook Object Model. ESM, EWS, CDO & RDO (deprecated as they are) all have the same issue. So if you are just trying to wipe everything you're good, but if you're filtering first, exercise caution.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM