所以我试图在AD中查询一个组,然后使用该列表创建一个电子邮件地址列表。我正在使用以下命令:
Get-ADGroupMember mygroup -Server my.server.com | Select-Object SID | Get-ADUser -Identity $_.SID -Properties cn,mail -server my.server.com | Select-Object Samaccountname,mail | Format-Table Samaccountname,mail
当我运行此程序时,我会得到以下错误。
Get-ADUser:无法验证参数"Identity"的参数。参数为null,或者参数集合的某个元素包含null值。
行:1字符:107
。。。用户-标识$_.SID-属性cn,邮件-服务器na.ko.com |选择对象Sama。。。
- CategoryInfo:InvalidData:(:)[Get-ADUser],ParameterBindingValidationException
- FullyQualifiedErrorId:ParameterArgumentValidationError,Microsoft.ActiveDirectory.Management.Commands.GetADUser
有人想教一个新手吗?
要使其成为一个答案,您可以跳过Select语句,并通过ForEach循环运行Get-ADUSer:
Get-ADGroupMember mygroup -Server my.server.com | ForEach{ Get-ADUser -Identity $_.SID -Properties cn,mail -server my.server.com | Format-Table Samaccountname,mail