OU中的用户列表和某个sec组的成员

时间:2014-03-05 22:47:54

标签: powershell active-directory

我有两个列表,一个包含某个OU的所有成员。另一个列出了一个sec组的所有成员。我想比较两个列表并编译两个列表中的用户列表。有人在正确的方向上推动我吗?

get-adgroupmember [sec group] | FT Name | out-file "path\file.csv"
get-aduser -filter * searchbase "Conical path of OU" | FT Name | out-file "path\file.csv"

将这两个命令抛入变量[arrays]并使用compare-object实际上并没有告诉我多少。这是

的输出片段

InputObject SideIndicator ------------- Microsoft.PowerShell.Commands.Internal.Format.FormatStartData == Microsoft.PowerShell.Commands.Internal.Format.GroupStartData == Microsoft.PowerShell.Commands.Internal.Format.FormatEntryData == Microsoft.PowerShell.Commands.Internal.Format.FormatEntryData == Microsoft.PowerShell.Commands.Internal.Format.FormatEntryData == Microsoft.PowerShell.Commands.Internal.Format.FormatEntryData == Microsoft.PowerShell.Commands.Internal.Format.FormatEntryData == Microsoft.PowerShell.Commands.Internal.Format.FormatEntryData == Microsoft.PowerShell.Commands.Internal.Format.FormatEntryData == Microsoft.PowerShell.Commands.Internal.Format.FormatEntryData == Microsoft.PowerShell.Commands.Internal.Format.FormatEntryData ==

1 个答案:

答案 0 :(得分:1)

根本不需要第二次搜索。用户的OU位置隐含在其可分辨名称中:

$ou = 'ou=Execs,ou=Operations,dc=domain,dc=tld'

get-adgroupmember [sec group] |
 where $_.distinguishedname -like "*$ou"