domain users vs group membership

G

Gary Hunter

How do I easily generate a list of Domain users and their
group membership?
 
J

Jerold Schulman

How do I easily generate a list of Domain users and their
group membership?


Using GetUsers from tip 7964 in the 'Tips & Tricks' at http://www.jsiinc.com

@echo off
setlocal
set space= #
set space=%Space:~0,30%
for /f "Tokens=*" %%u in ('getusers') do (
set user=%%u
set OK=N
for /f "Skip= 24 Tokens=*" %%g in ('net user "%%u" /domain^|Findstr /l /n /v
/c:"[[*$]]"') do (
REM The above two lines are one line
set line=%%g
call :group
)
)
endlocal
goto :EOF
:group
if /i "%line:~3,34%" EQU "The command completed successfully" @echo\ &goto :EOF
if "%OK%" EQU "Y" goto Group2
if /i "%line:~3,11%" EQU "Local Group" goto Group1
if /i "%line:~3,12%" EQU "Global Group" goto Group1
goto :EOF
:Group1
set OK=Y
set usr=%user% #
set usr=%usr:~0,30%
set line=%line:~3%
@echo %usr%%line%
goto :EOF
:Group2
set line=%line:~3%
if "%line%" EQU "" goto :EOF
@echo %space%%line%

Jerold Schulman
Windows: General MVP
JSI, Inc.
http://www.jsiinc.com
 

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. After that, you can post your question and our members will help you out.

Ask a Question

Top