[英]PowerShell Get-ADUser with ANR
I'm trying to search Active Directory for a user with the following statement, but I get an error when I use $("smtp:$user").我正在尝试使用以下语句在 Active Directory 中搜索用户,但在使用 $("smtp:$user") 时出现错误。
get-aduser -filter {(anr -eq $user) -or (anr -eq $("smtp:$user"))}
Could anyone explain why please, or is there a better way of achieving the same result.任何人都可以解释为什么请,或者有更好的方法来实现相同的结果。 I would like user to be able to contain, Name, email or SAM information, and use the same code to search.
我希望用户能够包含,姓名,email 或 SAM 信息,并使用相同的代码进行搜索。
get-aduser: Cannot process argument because the value of argument "path" is not valid. get-aduser:无法处理参数,因为参数“路径”的值无效。 Change the value of the "path" argument and run the operation again.
更改“路径”参数的值并再次运行该操作。
At line:1 char:1 .在行:1 字符:1 。
get-aduser -filter {(anr -eq $user) -or (anr -eq $("smtp:$user"))} get-aduser -filter {(anr -eq $user) -or (anr -eq $("smtp:$user"))}
CategoryInfo:NotSpecified: (:) [Get-ADUser], PSArgumentException CategoryInfo:NotSpecified: (:) [Get-ADUser], PSArgumentException
FullyQualifiedErrorId:ActiveDirectoryCmdlet:System.Management.Automation.PSArgumentException,Microsoft.ActiveDirectory.Management.Commands.GetADUser FullyQualifiedErrorId:ActiveDirectoryCmdlet:System.Management.Automation.PSArgumentException,Microsoft.ActiveDirectory.Management.Commands.GetADUser
I'm not sure exactly what you are trying to achieve, as the first condition will include anything in the second condition.我不确定你到底想达到什么目的,因为第一个条件将包括第二个条件中的任何内容。
Does this look better?:这看起来更好吗?:
$user = "SmithJ"
$SMTP = "smtp:$user"
Get-ADUser -Filter {anr -eq $user -or anr -eq $SMTP}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.