JSI Tip 4509. How do I generate a list of the members of a domain group?

If you don't have Showmbrs from the resource kit, use GroupList.bat. The syntax is:

GroupList GroupName OutputFileName

GroupList.bat contains:

@echo off
if \{%1\}

\{\} goto syntax if \{%2\}

\{\} goto syntax set grp=%1 set file=%2 if exist %file% del /q %file% for /f "Skip=8 Tokens=*" %%i in ('net group %grp% /domain') do set line=%%i&call :parse endlocal goto :EOF :syntax @echo Syntax GroupList GroupName OutputFileName endlocal goto :EOF :strip set short=%name%# set short=%short: =% set short=%short: #=#% set short=%short:#=% @echo %short%>>%file% goto :EOF :parse set name=%line:~0,25% If /i "%name%" EQU "The command completed suc" goto :EOF call :strip set name=%line:~25,25% if not "%name%" EQU "" call :strip set name=%line:~50,25% if not "%name%" EQU "" call :strip
NOTE: To enumerate a local group, create LocalGroupList.bat, replacing:

('net group %grp% /domain')


('net localgroup %grp%')

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.