【发布时间】:2012-10-16 06:59:05
【问题描述】:
我正在处理这个 powershell 脚本来处理交换邮箱,其中一个参数(在我必须运行的许多命令中)需要在 RecipientFilter 下嵌入一个变量。无论我做什么类型的扩展,它总是按字面意思(作为$前缀)而不是扩展它。我不确定是否有一种特殊的方式我应该逃避它,或者什么。想法?
$prefix="FAKEDOM"
New-AddressList -name "AL_${prefix}_Contacts" -RecipientFilter {(RecipientType -eq 'MailContact') -and (CustomAttribute15 -eq $prefix)}
编辑:固定变量名。请注意,问题是针对 $prefix 的第二次使用,第一次使用正常。
编辑:工作解决方案:
New-AddressList -name "AL_${prefix}_Contacts" -RecipientFilter "(RecipientType -eq 'MailContact') -and (CustomAttribute15 -eq `"${prefix}`" )"
【问题讨论】:
-
您的代码已更新,但问题文本仍然提到 $fakedom。
-
叹息,再次更新,谢谢
标签: powershell exchange-server