创建transport rule遭遇错误The sequence of predicates is invalid

本来要创建一个transport rule

代码如下:

$Condition = Get-TransportRulePredicate FromAddressContains
$Condition.words = @("externaluser1@gmail.com","externaluser2@gmail.com")
$Condition1 = Get-TransportRulePredicate SentTo
$Condition1.addresses = @(get-mailbox xunyang)
$Action = Get-TransportRuleAction DeleteMessage
New-TransportRule -Name "Deny Senders to Cellulardeals" -Condition @($Condition,$condition1) -Actions @($Action)

看起来是没有问题的吧

结果遭遇错误The sequence of predicates is invalid

换一下代码后(其实就是两个条件位置换了一下):

$Condition = Get-TransportRulePredicate SentTo
$Condition.addresses = @(get-mailbox xunyang)
$Condition1 = Get-TransportRulePredicate FromAddressContains
$Condition1.words = @("externaluser1@gmail.com","externaluser2@gmail.com")
$Action = Get-TransportRuleAction DeleteMessage
New-TransportRule -Name "Deny Senders to Cellulardeals" -Condition @($Condition,$condition1) -Actions @($Action)

ok了。

image

原因嘛:

image

还是transport rule比较傻,必须先得send to,然后才能from包含。如果你也遇到这个问题,没办法了,把步骤换一下就可以了。

分享到