From: Rich Matheisen [MVP] on
On Wed, 17 Feb 2010 01:58:58 -0800 (PST), Luuke <luuke57(a)gmail.com>
wrote:

>Here we go :
>
>$Condition1 = get-transportrulepredicate From
>$Condition1.addresses = @(get-mailbox "Luuke 57")
>$Exception1 = get-transportrulepredicate HasClassification
>$Exception1.classification = (get-messageclassification
>"CL1").Identity
>$Exception2 = get-transportrulepredicate HasClassification
>$Exception2.classification = (get-messageclassification
>"CL2").Identity
>$Action1 = get-transportruleaction RejectMessage
>$Action1.RejectReason = "Missing classification"
>new-transportrule -name "Test" -Exceptions @($Exception1, $Exception2)
>-Conditions @($Condition1) -Action @($Action1)
>
>New-TransportRule : The sequence of predicates is invalid.
>Parameter name: Exceptions
>At line:1 char:18
>+ new-transportrule <<<< -name "Test" -Exceptions @($Exception1,
>$Exception2)
>-Conditions @($Condition1) -Action @($Action1)

Well, bad news. :-(

The problem is that you can have only one test of any predicate in a
transport rule.

The good news is that doing what you want isn't impossible, it just
has to be done another way.

See if this works (I haven't tested it so it may not be syntactically
correct):

$Condition1 = get-transportrulepredicate From
$Condition1.addresses = @(get-mailbox "E2K7")

$Action1 = Get-TransportRuleAction SetHeader
$Action1.MessageHeader = "X-ClassificationFound"
$Action1.HeaderValue = "OK"

$Exception1 = get-transportrulepredicate HasClassification
$Exception1.classification = (get-messageclassification
ExACPrivileged).Identity

New-Transportrule -name "Test1" -Exceptions @($Exception1) -Conditions
@($Condition1) -Action @($Action1)

$Exception2 = get-transportrulepredicate HasClassification
$Exception2.classification = (get-messageclassification
ExCompanyInternal).Identity

New-Transportrule -name "Test2" -Exceptions @($Exception2) -Conditions
@($Condition1) -Action @($Action1)

$Action3 = get-transportrulepredicate RejectMessage
$Action3.RejectReason = "Missing Classification"
$Action3.EnhancedStatusCode = "5.7.1"

$Exception3 = get-transportrulepredicate HeaderContains
$Exception3.MessageHeader = "X-ClassificationFound"
$Exception3.Words = @("OK")

New-Transportrule -name "Test3" -Exceptions @($Exception3) -Conditions
@($Condition1) -Action @($Action3)
---
Rich Matheisen
MCSE+I, Exchange MVP
From: Luuke on
Hi RIch,

Thanks for this. Just one error in the $Action3 (should read get-
transportruleaction).

I tried it, but the message with no classification has been delivered.
If a rule is matched, does Exchange process other rules as well or
does it stop ?
Or it may be a problem with the priority on the rules ? Currently rule
3 has priority 2, rule 1, 0 and rule 2, 1.

I will continue to investigate in your direction, thanks.

Luuke
From: Rich Matheisen [MVP] on
On Fri, 19 Feb 2010 03:51:55 -0800 (PST), Luuke <luuke57(a)gmail.com>
wrote:

>Hi RIch,
>
>Thanks for this. Just one error in the $Action3 (should read get-
>transportruleaction).
>
>I tried it, but the message with no classification has been delivered.
>If a rule is matched, does Exchange process other rules as well or
>does it stop ?
>Or it may be a problem with the priority on the rules ? Currently rule
>3 has priority 2, rule 1, 0 and rule 2, 1.
>
>I will continue to investigate in your direction, thanks.

The rules that add the header must run before the rule that checks to
see if the header exists.
---
Rich Matheisen
MCSE+I, Exchange MVP