powershell tr​​ansportrule - 在变量中设置多个组

时间:2014-09-19 17:52:53

标签: powershell powershell-ise

我尝试使用PowerShell在Office 365中生成传输规则。在powershell脚本中执行时,第一个命令的行为不符合预期。但是,第二个命令在powershell中手动执行时会成功。看来,当存储到变量时,只设置提供的第一个地址,而完全忽略第二个地址。我是否滥用变量或其他类别的" duh"?

来自剧本:

$groupfilter="distribution2@foo.bar,distro@foo.bar"
set-transportrule -Identity "Filtering - Received Mail" -SentToMemberOf $groupfilter

通过powershell手动执行:

set-transportrule -Identity "Filtering - Received Mail" -SentToMemberOf distribution2@foo.bar,distro@foo.bar

1 个答案:

答案 0 :(得分:1)

据我所知-SentToMemberOf接受一个数组。来自Help Set-TransportRule

[-SentToMemberOf <RecipientIdParameter[]>]

你应该改变这一行

$groupfilter="distribution2@foo.bar,distro@foo.bar"

数组而不是以逗号分隔的字符串。

$groupfilter="distribution2@foo.bar","distro@foo.bar"
相关问题