list all groups and members of those groups

Discussion in 'Scripting' started by Villain, May 18, 2006.

  1. Villain

    Villain Guest

    Does anyone know of a script that will display a list of all groups on
    a domain as well as the members of those groups?

    I can deal with it showing global, local, distribution, etc. groups.
    However, I need to find a way to export the entire tree, showing
    groups and their members, to an excel document.

    I have searched the internet, and I can't find something that does
    this. I could go through and do each group one by one, however, we
    have several distribution groups setup for email, and sifting through
    them all one at a time is difficult. If I could display all of them
    in one shot, that would make things easier.

    Thank you
    Villain, May 18, 2006
    1. Advertisements

  2. Hi,

    I have a sample VBScript program to document all groups in the domain linked
    here: Domain Groups.htm

    The output can be redirected to a text file. Formatting the output for a
    spreadsheet takes some thought. A group could have hundreds or thousands of
    members. I don't see how it could be done off hand, although you can import
    the text file into Excel.

    To document a single group, see this example: Members of a Group.htm

    The first program documents group direct membership. Membership due to group
    nesting can be determined from the results since groups are listed as
    members, but "primary" group membership is not documented. The second
    program reveals direct membership, membership due to nesting, and "primary"
    group membership.

    It would be very difficult to modify the first program to document "primary"
    group membership. Better to assume that every user has "Domain Users"
    designated as their "primary" and every computer has "Domain Computers".
    Richard Mueller, May 18, 2006
    1. Advertisements

  3. Villain

    Villain Guest

    This seems to have gotten what I'm looking for. Thank you for the

    I'm working on a way to import the data into Excel. If there's a way
    to tab delimit the data, that might help, but I'm not sure of the best
    way to do that yet.
    Villain, May 18, 2006
  4. I often code scripts to output semicolon delimited fields (since
    distinguished names have embedded commas). If I redirect the output to a
    text file, this can be imported into a spreadsheet. Or, the script can use
    the FileSystemObject to write the lines of semicolon delimited values to a
    text file. Or the script can write to cells in a spreadsheet. The problem
    here is the format of the spreadsheet. As I recall you are limited to 256
    columns, which would not accomodate a large group. Here is a sample program
    that outputs to an Excel spreadsheet: User List 3.htm

    This only writes to one column, but you can assign values to any cell with:

    objSheet.Cells(intRow, intCol).Value = strValue

    where intRow is the row number and intCol is the column number. The first
    cell is row 1, column 1. If you put the group name in the first column, and
    members in subsequent columns, you would be limited to 255 members in any
    group. Plus, the spreasheet would require a lot of scrolling. You could put
    the first group name in objSheet.Cell(1, 1), then the members of this group
    in objSheet.Cell(2, 2) thru objSheet.Cell(x, 2), then the next group name in
    objSheet(x + 1, 1), etc. But this seems no more convenient than a text file.

    Another example program that creates a spreadsheet: to Excel.htm
    Richard Mueller, May 19, 2006
  5. See tip 9244 ยป How can I generate a CSV file of all domain group membership?
    in the 'Tips & Tricks' at

    Jerold Schulman
    Windows Server MVP
    JSI, Inc.
    Jerold Schulman, May 19, 2006
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.