A Quick Tip To Get Members Of Security Groups

  • Section(s): Administrator, Admin , Admin
  • Published on Sep 17, 2009.
  • Last Modified on Apr 04, 2009.
  • Last Modified by Nirmal Sharma.
  • Rated 5 out of 5 based on 1 votes.
This article explains a command which you can use to get the members of security group or security groups mentioned in a text file.

The below command can be used to 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.

Required files:

Please make sure you have the below mentioned files on the computer where you are running the above command.

  • DSQuery
  • DsGet

About Nirmal Sharma

Nirmal is a Microsoft MVP in Directory Services and working as a Technical Architect/Consultant. He has been involved in Microsoft Technologies since 1994 and followed the progression of Microsoft Operating Systems and software. He is specialized in Directory Services, Microsoft Clustering, SQL, MOM, Exchange and Citrix. In his spare time, he likes to help others and write "internal" technical articles, white papers and tips on various Microsoft technologies. You can contact him at nirmal_sharma@mvps.org.


Article not looking right or info is missing? Let us know so that we can fix it: .


Receive all the latest articles by email!

Receive Real-Time & Monthly WindowsNetworking.com article updates in your mailbox. Enter your email below!
Click for Real-Time sample & Monthly sample

Become a WindowsNetworking.com member!

Discuss your network issues with thousands of other network administrators. Click here to join!

Community Area

Log in | Register

Readers' Choice

Which is your preferred network administration tool?