JSI Tip 8015. Report local and global group membership of all users.

Using GetUsers.bat, I have scripted UsrGroups.bat to report all user's local and global group membership.

When you run UsrGroups, the output is displayed on the console, but you can pipe it to a file using:


UsrGroups.bat contains:

@echo off
set space=                              #
set space=%Space:~0,26%
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 (
 set line=%%g
 call :group
goto :EOF
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
set OK=Y
set usr=%user%                               #
set usr=%usr:~0,26%
set line=%line:~3%
@echo %usr%%line%
goto :EOF
set line=%line:~3%
if "%line%" EQU "" goto :EOF
@echo %space%%line%

Hide comments


  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.