得到命令行用户的未截断Active Directory组(Get user's non-tr

2019-08-08 17:04发布

我经常使用的net user命令来看看AD组的用户:

net user /DOMAIN <username>

这种运作良好,但组名称被截断为大约20个字符。 而在我的组织,大多数组的名称是比这长得多。

有谁知道的方式通过命令行来获得未截断的广告组?

Answer 1:

你可以解析从GPRESULT命令的输出。



Answer 2:

GPRESULT是正确的命令,但不能带参数运行。 /v或详细选项是不困难也输出到一个文本文件来管理。 EG我推荐使用

gpresult /user myAccount /v > C:\dev\me.txt --Ensure C:\开发\ me.txt存在

另一种选择是显示摘要信息仅可以是在命令窗口完全可见:

gpresult /user myAccount /r

该账户项下所列:

The user is a part of the following security groups
---------------------------------------------------


Answer 3:

有点陈旧的职位,但我想通什么的挫折感。 难道“WHOAMI”满足您的需求?

我今天刚刚发现了它(从把我带到这里,实际上是同谷歌搜索)。 Windows已经有自XP(在工具包附加的一部分)WHOAMI工具,因为Vista中已经内置。

whoami /groups

列出所有的AD组为当前登录的用户。 我认为它需要你以管理员身份登录该用户,虽然如此,如果你的使用情况,需要运行命令来看看其他用户的能力,这也无济于事。



Answer 4:

或者你可以使用DSQUERYDSGET:

dsquery user domainroot -name <userName> | dsget user -memberof

要检索组成员是这样的:

Tue 09/10/2013 13:17:41.65
C:\
>dsquery user domainroot -name jqpublic | dsget user -memberof
"CN=Technical Support Staff,OU=Acme,OU=Applications,DC=YourCompany,DC=com"
"CN=Technical Support Staff,OU=Contosa,OU=Applications,DC=YourCompany,DC=com"
"CN=Regional Administrators,OU=Workstation,DC=YourCompany,DC=com"

虽然我无法找到我曾经在我的电脑上安装该软件包的任何证据,你可能需要安装远程服务器管理工具的Windows 7。



Answer 5:

使用PowerShell: Windows PowerShell中使用Active Directory

快速提示-使用PowerShell确定AD组成员



Answer 6:

基于由P.Brian.Mackey--答案我尝试使用gpresult /user <UserName> /r命令,但它似乎只为我的用户帐户的工作; 其他用户帐户,我得到这个结果: The user "userNameHere" does not have RSOP data

因此,我通过这个blog--阅读https://blog.thesysadmins.co.uk/group-policy-gpresult-examples.html--并在一个解决方案来。 你必须知道用户的计算机名:

gpresult /s <UserComputer> /r /user:<UserName>

运行该命令后,你必须ENTER几次的程序来完成,因为它会在输出中的中间暂停。 此外,结果给了一组数据,包括对“一节COMPUTER SETTINGS> Applied Group Policy Objects ”,然后在“ COMPUTER SETTINGS> Security groups ”,最后是“ USER SETTINGS> security groups ”(这就是我们正在寻找的与非截断描述中列出的AD组!)。

有趣的是,GPRESULT曾在NET USER命令没有看到一些额外的成员。 另外,排序顺序不匹配,而不是按字母顺序排列。 任何机构谁能够在这将是巨大的注释添加更多的见解。

结果: gpresult (with ComputerName, UserName)

为了安全起见,我只包括隶属结果的子集。 (36 TOTAL,12 SAMPLE)

The user is a part of the following security groups
---------------------------------------------------
..
 Internet Email 
 GEVStandardPSMViewers  
 GcoFieldServicesEditors    
 AnimalWelfare_Readers  
 Business Objects   
 Zscaler_Standard_Access    
..
 GCM    
..
 GcmSharesEditors   
 GHVStandardPSMViewers  
 IntranetReportsViewers 
 JetDWUsers     -- (NOTE: this one was deleted today, the other "Jet" one was added)
..
 Time and Attendance Users  
..

结果: net user /DOMAIN (with UserName)

为了安全起见,我只包括隶属结果的子集。 (23 TOTAL,12 SAMPLE)

Local Group Memberships  
Global Group memberships    ...
                             *Internet Email       *GEVStandardPSMViewers
                             *GcoFieldServicesEdito*AnimalWelfare_Readers
                             *Business Objects     *Zscaler_Standard_Acce
                             ...
                             *Time and Attendance U*GCM
                             ...
                             *GcmSharesEditors     *GHVStandardPSMViewers
                             *IntranetReportsViewer*JetPowerUsers
The command completed successfully.


文章来源: Get user's non-truncated Active Directory groups from command line