我试图让所有组用户是成员,甚至嵌套的人(recusively),在PowerShell中我使用:
I'm trying to get ALL the groups a user is member, even the nested ones (recusively), in Powershell I'm using:
(Get-ADUser <username> -Properties MemberOf | Select-Object MemberOf).MemberOf
但它只返回组的用户是直接的成员,就像你使用AD用户控制台时得到的。所有组的I单列表是非常有帮助的,就像从G presult -r的输出,它显示了所有组的用户是成员。
But it only returns the groups the user is a "direct" member, like you get when using the AD users console. I single list of ALL the groups is very helpful, like the output from "gpresult -r", where it shows ALL the groups the user is a member.
有没有办法从任何AD用户怎么做呢? (犯规必须完全在PowerShell中,也许孤单,我不知道另一种工具)
Is there a way to get it from any AD user? (Doesnt need to be exclusively in Powershell, maybe theres another tool that I dont know yet)
感谢。
您可以使用的 LDAP_MATCHING_RULE_IN_CHAIN :
Get-ADGroup -LDAPFilter "(member:1.2.840.113556.1.4.1941:=CN=User,CN=USers,DC=x)"
您可以使用它anywahere,您可以使用LDAP过滤器。
You can use it anywahere that you can use an LDAP filter.
示例:
$username = 'myUsername'
$dn = (Get-ADUser $username).DistinguishedName
Get-ADGroup -LDAPFilter ("(member:1.2.840.113556.1.4.1941:={0})" -f $dn) | select -expand Name | sort Name