Quantcast
Viewing all articles
Browse latest Browse all 8719

Multiple "FromAddressContainsWords" Conditions in One Rule via PowerShell?

My organization recently moved to Exchange Online and I am looking at trying to convert the old mail rules from our old system (Sieve rules from Zimbra) to something that will work in Exchange Online.  My plan is to massage the Sieve output into New-InboxRule statements.  The massaging part is the easy part.  What I'm having difficult with is using PowerShell to recreate a rule that should have multiple -FromAddressContainsWords parameters.  Here's what I started off with:


New-InboxRule -Name "Annoyances" -FromAddressContainsWords roxioemail.com -FromAddressContainsWords "Covalent Technologies" -FromAddressContainsWords process.con -FromAddressContainsWords gateway@regconfirmation.com -DeleteMessage $true -StopProcessingRules -Mailbox George.Lenzer

This didn't work as the -FromAddressContainsWords option can only be used once.  The error also suggested trying to do an array if the parameter would accept one.  I don't know, because that isn't documented anywhere.  The only thing mentioned in the help is that it will take a "MultivaluedProperty" which I assume means some sort of string or array that has multiple values in it.

I then tried this:

New-InboxRule -Name "Junk Mail" -FromAddressContainsWords {roxioemail.com; Covalent Technologies; process.com; gateway@regconfirmation.com} -DeleteMessage $true -StopProcessingRules $true -Mailbox George.Lenzer

While this worked, when I went into OWA to look at the rule and check the list of words, instead of each word on it's own line, had a single entry containing everything between { and }.  This doesn't look right, and I don't expect it would do what I want.  So how does one go about creating an Inbox rule from PowerShell that needs to check multiple conditions, some of the identical type?  It can be done from the GUI, so there must be a way to do it from PowerShell.  Any suggestions?


Viewing all articles
Browse latest Browse all 8719

Trending Articles