如何获得所有广告用户组(递归)使用PowerShell或其他工具? [英] How to get ALL AD user groups (recursively) with Powershell or other tools?

查看:198
本文介绍了如何获得所有广告用户组(递归)使用PowerShell或其他工具?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图让所有组用户是成员,甚至嵌套的人(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

这篇关于如何获得所有广告用户组(递归)使用PowerShell或其他工具?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆