我正在尝试使用以下命令获取某个 AD 安全组中的用户及其描述/部门的列表:
Get-ADGroupMember -Identity "SecurityGroup" | select samaccountname,description,department
此查询提取用户名 (samaccountname),但描述和部门留空。我还尝试了以下所有方法:
| select-object samaccountname,description,department
| select-object -property samaccountname,description,department
| select -property samaccountname,description,department
有人能告诉我这个的正确语法吗?
谢谢
答案1
我需要将输出导入 Get-ADUser 来提取附加信息。
Get-ADGroupMember -Identity "SecurityGroup" | Get-ADUser -properties samaccountname, department, description | format-table samaccountname, department, description | Out-File SecurityGroup.txt