Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I am setting up a user group and user audit/review process. For this I am looking for a script that can easily generate a list of groups and the assigned users. E.g.:

share|improve this question
Are you looking for domain groups or local computer groups? and do you have to worry about nested groups? –  Rex Mar 26 '12 at 3:35

2 Answers 2

You can use net localgroups to get a list of groups on the local machine, and net user to get a list of users. You can then use net user USERNAME to get a list of groups that the user is in. It will require a bit of scripting to put it all together though.

share|improve this answer

Paste this text in a batch file:

  @echo off

  for /f "delims=*" %%a in ('dsquery user -name * -limit 12000^|dsget user -samid') do Call :ShowUser %%a
  goto :eof

    set usr=%*
    If "%usr%"=="dsget succeeded" goto :eof
    for /f "delims=*" %%b in ('dsquery user -name * -limit 12000^|dsget user -memberof^|dsget group -samid') do if NOT "%%b"=="dsget succeeded" Echo %usr%  %%b
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.