我有这么长的一行,我想让它更容易阅读:
$Mail = "stantastic@example.com"
Get-ADUser -Server example.com:3268 -Filter {EmailAddress -eq $Mail} -Properties CN,co,Company,Department,DisplayName,SamAccountName,State,Office,EmailAddress
我读到使用飞溅很好,所以我正在尝试:
$Params = @{
Server = 'example.com:3268'
Filter = '{ EmailAddress -eq $Mail }'
Properties = 'CN,co,Company,Department,DisplayName,SamAccountName,State,Office,EmailAddress'
}
Get-ADUser @Params
但是运行它会引发错误:
Get-ADUser:解析查询时出错:“{ EmailAddress -eq stantastic@example.com }”错误消息:“语法错误”在位置:“1”。 在行:1 字符:1 + 获取 ADUser @Params +~~~~~~~~~~~~~~~~~~ + CategoryInfo : ParserError: (:) [Get-ADUser], ADFilterParsingException + FullyQualifiedErrorId : ActiveDirectoryCmdlet:Microsoft.ActiveDirectory.Management.ADFilterParsingException,Microsoft.ActiveDirectory.Management.Commands.GetADUser
我错过了什么?