小编loc*_*ost的帖子

Powershell参数变量扩展

我正在使用这个powershell脚本来处理交换邮箱,其中一个参数(在我必须运行的很多命令中)需要在RecipientFilter下嵌入一个变量.无论我做什么类型的扩展,它总是按字面意思(作为$前缀)进行评估,而不是扩展它.我不确定是否有一种特殊的方式我应该逃避它,或者是什么.想法?

$prefix="FAKEDOM"

New-AddressList -name "AL_${prefix}_Contacts" -RecipientFilter {(RecipientType -eq 'MailContact') -and (CustomAttribute15 -eq $prefix)}
Run Code Online (Sandbox Code Playgroud)

编辑:修改变量名称.请注意,问题是第二次使用$ prefix,第一次正常工作.

编辑:工作解决方案:

 New-AddressList -name "AL_${prefix}_Contacts" -RecipientFilter "(RecipientType -eq 'MailContact') -and (CustomAttribute15 -eq `"${prefix}`" )"
Run Code Online (Sandbox Code Playgroud)

powershell exchange-server

3
推荐指数
1
解决办法
3910
查看次数

标签 统计

exchange-server ×1

powershell ×1