EXPORTING MEMBERS OF AN ACTIVE DIRECTORY GROUP

A while back, my boss came to me, asking me if I could get him an export of the users that are members of two groups in Active Directory. For the purposes of this blog post, let’s call them “OfflineUsers” and “Software Access”. As it turns out, this is pretty easy to do.
Here’s how:
  1. Log on to your Domain Controller
  2. Open a command prompt
  3. Enter the command dsquery group -samid %GROUPNAME% | dsget group -members > filename.txt, substituting %GROUPNAME% for the name of the group, and replacing filename with something logical if you so desire:
  4. Go to the folder from which you run the command, and grab the text files
  5. A few things to remember here:
    1. You must enclose group names with spaces in quotes, like so:"Software Access
    2. You can specify what folder to store the file in, like so: > C:%GROUPNAME%.txt

Comments