PoshCode Archive  Artifact [b48223134e]

Artifact b48223134ecb792bf2ea7f06968e9543148ba67ec18ae8115c16165d3991c841:

  • File Get-UserWithManyGroups.ps1 — part of check-in [bae50a7c73] at 2018-06-10 12:56:58 on branch trunk — Lists Active Directory user accounts which are members of too many groups, and can thus cause token bloat issues (user: unknown size: 793)

# encoding: ascii
# api: powershell
# title: Get-UserWithManyGroups
# description: Lists Active Directory user accounts which are members of too many groups, and can thus cause token bloat issues
# version: 0.1
# license: CC0
# x-poshcode-id: 1385
# x-archived: 2010-07-17T01:51:28
#
#
# Lists AD users who are members in too many groups
# (c) Dmitry Sotnikov
# Details at:
# http://dmitrysotnikov.wordpress.com/2009/10/12/find-users-in-too-many-groups/
# Uses free Quest AD cmdlets

$limit = 75
Get-QADUser -SizeLimit 0 -DontUseDefaultIncludedProperties |
  ForEach-Object {
    $groups = Get-QADGroup -ContainsIndirectMember $_.DN -SizeLimit $limit `
      -DontUseDefaultIncludedProperties -WarningAction SilentlyContinue
    if ($groups.Count -ge $limit) { $_ }
  }