powershell - 获取 Active Directory 中的所有空组

标签 powershell quest

我一直想弄清楚如何获取所有空的 Active Directory 组。我想出了这个命令,它选择没有成员且不是任何成员的组。

Get-QADGroup -GroupType Security -SizeLimit 0 | where-object {$_.Members.Count -eq 0 -and $_.MemberOf.Count -eq 0} | select GroupName, ParentContainer | Export-Csv c:\emptygroups.csv

这基本上是正确的,但它说某些组,如默认组 Domain Computers 是空的,但它不是空的。这个特定组只有计算机成员,但似乎没有选择其他只有计算机的组。

有谁知道为什么这个命令会吸引一些有成员的人?

最佳答案

Get-QADGroup cmdlet 有一个参数 -Empty 。帮助中的描述提示了这些默认组被返回的原因:

Note: A group is considered empty if it has the "member" attribute not set. So, this parameter can retrieve a group that has only those members for which the group is set as the primary group. An example is the Domain Users group, which normally is the primary group for any user account while having the "member" attribute not set.



我不是很熟悉 Quest 的东西,但我能够通过这种方式找到空组(可能不是最有效的):
Get-ADGroup -Filter {GroupCategory -eq 'Security'} | ?{@(Get-ADGroupMember $_).Length -eq 0}

关于powershell - 获取 Active Directory 中的所有空组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11941929/

相关文章:

powershell - 如何让详细消息出现在 Start-Transcript 的输出中?

powershell - 并行运行Quest cmdlet并将输出保存到文件

unity3d - unity - oculus quest - 如何读取拇指输入

powershell - 检查用户是否是 AD 组列表的成员

sql-server - 调用-Sqlcmd : Duplicate column names are not permitted in SQL PowerShell

powershell - 选择对象省略了选择字符串Powershell的输出

powershell - Powershell 2.0-内存泄漏

oculus - React-360 Oculus Quest 不会进入 VR 模式

windows - midl 找不到 C 预处理器 cl.exe

powershell - Azure key 保管库 : Secret not found error