You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何基于多值扩展属性筛选Exchange动态通讯组?

解决动态通讯组筛选CustomAttribute2包含特定值的问题

Exchange动态通讯组的筛选规则基于OPATH语法,和PowerShell原生运算符的限制不同,直接使用开头带通配符的-like会触发错误,需针对逗号分隔的多值场景拆分筛选条件:

正确的筛选表达式

针对目标值123(或变量$variableName),需覆盖四种包含该值的场景,用-or组合:

# 直接匹配单个值
(CustomAttribute2 -eq '123') -or 
# 值在开头,后跟逗号
(CustomAttribute2 -like '123,*') -or 
# 值在中间,前后都有逗号
(CustomAttribute2 -like '*,123,*') -or 
# 值在结尾,前跟逗号
(CustomAttribute2 -like '*,123')

如果使用变量,确保用双引号包裹通配符部分,让变量正确解析:

$targetValue = '123'
$filter = "(CustomAttribute2 -eq '$targetValue') -or (CustomAttribute2 -like '$targetValue,*') -or (CustomAttribute2 -like '*, $targetValue,*') -or (CustomAttribute2 -like '*, $targetValue')"

原方案错误原因

  1. 第一种方案未覆盖值在中间的情况(如765,123,626),且单引号包裹变量会导致变量被解析为字面量而非实际值;
  2. 第二种方案使用*$variableName*,OPATH语法不允许-like表达式以通配符开头,因此触发报错。

验证场景

该筛选器可覆盖所有符合要求的用户:

  • CustomAttribute2为单个值123
  • CustomAttribute2为123,456(值在开头)
  • CustomAttribute2为456,123,789(值在中间)
  • CustomAttribute2为456,123(值在结尾)

内容的提问来源于stack exchange,提问作者ajjar

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.13 15:55:03