Blog‎ > ‎

Get Members of Windows Security Groups

posted Sep 12, 2012, 3:35 AM by Andre Rossouw   [ updated Sep 12, 2012, 3:36 AM ]

Get the list of members of a security groups mentioned in a text file. This is very useful when you want a list of user accounts for Security Groups.

Steps:

  1. Create a text file: GroupNames.txt
  2. Copy all the group names (do not copy the DN of the Group, only the group name. For example, Administrator)
  3. Run the following command:

For /f "Tokens=*" %a in (GroupNames.txt) Do DsQuery group -name "%a" | DsGet group -members -expand > GroupName_%a.txt

The above command will create a file by that group name and all the members of that group will be saved in that group file.

Comments