Take the 2-minute tour ×
Server Fault is a question and answer site for professional 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.:

Administrators/Administrator
Administrators/Account1
Administrators/Account2
SomeOtherGroup/Accounts2
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
add comment

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
add comment

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

  :ShowUser
    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
add comment

Your Answer

 
discard

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.