1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | # # Enumerate All Users for a Group (including traversing nested groups) # @param distinguishedName - The distinguished name of the object you want to traverse # Brock Moeller # 12/16/2009 # param ( $distinguishedName = "CN=SuperGroup,OU=Groups,DC=serv,DC=ubercorp,DC=com" ) $roles = @{}; $indent = -1; filter EnumMember { $indent += 1; if ($_ -is [System.DirectoryServices.DirectoryEntry]){ $adsiObj = $_; } else { } if (( -not [String]::IsNullOrEmpty( $adsiObj .cn)) -and ( -not $roles .ContainsKey( $adsiObj .cn))){ $roles [ $adsiObj .cn] = 1; $memberOfCount = $adsiObj .member.Count; $( "`t" * $indent ) + $adsiObj .cn + " [$memberOfCount]" ; if (( $memberOfCount -gt 0) -and ( $indent -lt 900)) { $adsiObj .member | EnumRoles; } } $indent -= 1; } $user ; $buffer = $user .Path + "`n" ; $user | EnumMember | % { $buffer += $_ + "`n" }; "Buffer: " + $buffer .ToString(); [System.IO.File]::WriteAllText( "$pwd\$($user.cn).txt" , $buffer .ToString()); |
Sunday, January 31, 2010
Enumeration of All Users in a Group (traversing nested groups) in Active Directory
As a counter part to my previous post, I created a dual of the script which enumerates Groups and their members.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment