具有直接报告的ADGroup中的用户 [英] Users in ADGroup with direct reports
问题描述
我想要 ATL用户
中具有直接报告的用户列表.
I want a list of users in ATL Users
that have direct reports.
第1部分:组成员身份
我可以将用户分组.
Get-ADGroupMember "ATL Users" | Where objectClass -eq "user"
第2部分:直接报告过滤器
我可以获得具有直接报告的用户列表,但是速度非常慢(扫描整个树).
I can get a list of users with direct reports, but very slowly (scans entire tree).
Get-ADUser -Filter "DirectReports -like '*'"
问题
如果有直接报告,如何在 ATL用户
中然后在 -Filter
中获得这些用户的列表?
How can I get the list of users in ATL Users
then -Filter
those users by if they have direct reports?
推荐答案
通过使用memberOf的LDAP过滤器可以轻松完成此操作.如果这是一次性查询,并且您知道该组的专有名称(在此示例中为cn = ATL用户,ou = groups,dc = domain,dc = gTLD),则可以使用:
This is readily done with an LDAP filter using memberOf. If this is a one-off query and you know the group's distinguished name (cn=ATL Users,ou=groups,dc=domain,dc=gTLD in this example), you can use:
get-aduser -LDAPFilter "(&(memberOf=cn=ATL Users,ou=groups,dc=domain,dc=gTLD)(directReports=*)(objectClass=user))"
如果您将重复运行此查询,则最好从搜索中获取组对象,以便目录重组不会破坏您的查询.
If you will be running this query repeatedly, it would be best to get the group object from a search so directory restructuring won't break your query.
PS> $groupFQDN = (get-adgroup -identity "ATL Users").distinguishedName
PS> $groupFQDN
CN=ATL Users,OU=NewGroupsOU,DC=company,DC=gTLD
PS> get-aduser -LDAPFilter "(&(memberOf=$groupFQDN)(directReports=*)(objectClass=user))"
这篇关于具有直接报告的ADGroup中的用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!