PoshCode Logo PowerShell Code Repository

Get-UserWithManyGroups by Dmitry Sotnikov 28 months ago
embed code: <script type="text/javascript" src="http://PoshCode.org/embed/1385"></script>download | new post

Lists Active Directory user accounts which are members of too many groups, and can thus cause token bloat issues

  1. # Lists AD users who are members in too many groups
  2. # (c) Dmitry Sotnikov
  3. # Details at:
  4. # http://dmitrysotnikov.wordpress.com/2009/10/12/find-users-in-too-many-groups/
  5. # Uses free Quest AD cmdlets
  6.  
  7. $limit = 75
  8. Get-QADUser -SizeLimit 0 -DontUseDefaultIncludedProperties |
  9.   ForEach-Object {
  10.     $groups = Get-QADGroup -ContainsIndirectMember $_.DN -SizeLimit $limit `
  11.       -DontUseDefaultIncludedProperties -WarningAction SilentlyContinue
  12.     if ($groups.Count -ge $limit) { $_ }
  13.   }

Submit a correction or amendment below (
click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Syntax highlighting:


Remember me