header1   header
header
header Register : : Login header
header
connector   connector
menuleft menuright
submenu   submenu
left
List users that are in following groups
Last Post 24 Oct 2011 04:25 AM by serokles. 0 Replies.
Printer Friendly
  •  
  •  
  •  
  •  
  •  
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
seroklesUser is Offline
New Member
New Member
Posts:9
Avatar

--
24 Oct 2011 04:25 AM
    I have managed to ham fist a decent answer to the following problem but I am absolutely certain that there is an easier or more elegant way to do this so here goes.

    I have three AD groups and users are members of all, several or none of them depending.  What I am trying to achieve is a count of all the unique users in these three groups.

    I have been trying to use the official tools from Server 2008 R2 to do this and was able to get a result by running a get-adgroupmember for each group, exporting/appending to a text file, sorting and then piping to get-unique.  This works but if I run a count against this it includes a count of the two separator lines at the begining of the text file.  Not a real problem but annoying.

    Is there a better way to do this?  I was looking at a compare-object style approach but this only compares two objects.

    The commands I ran so far:

    First command ran for each group in question:

    get-adgroupmember -Identity "Office 2007 SP2" | ft -Property samaccountname | out-file -Append users.txt

    Then:

    get-content users.txt | sort | get-unique > unique.txt

    followed by a count of that text file.  Longwinded but I can't seem to think of a way to do this without resorting to using Quest tools.  Any help greatly appreciated.
    You are not authorized to post a reply.


    Active Forums 4.3
    right
    footer   footer
    footer Sponsored by Quest Software • SAPIEN Technologies • Compellent • Microsoft Windows Server 2008 R2 footer
    footer   footer