@ECHO OFF ECHO. :: Check Windows version IF NOT "%OS%"=="Windows_NT" GOTO Syntax :: Check number of command line arguments IF "%~1"=="" GOTO Syntax IF NOT "%~2"=="" GOTO Syntax :: Check both availability of DSQUERY and validity of command line argument DSQUERY.EXE User -samid %1 2>NUL | FIND.EXE "=" >NUL || GOTO Syntax :: The actual command is only one single line DSQUERY.EXE User -samid %1 | DSGET.EXE User -memberof -expand | SORT.EXE | FINDSTR.EXE /R /B /V /C:" samid" | FINDSTR.EXE /R /B /V /C:"dsget succeeded" GOTO:EOF :Syntax ECHO MemberOf.bat, Version 1.00 for Windows 2000 / XP / Server 2003 ECHO Recursively list all groups of which the specified user is a member. ECHO. ECHO Usage: MEMBEROF user_id ECHO. ECHO Where: "user_id" is the (SAM) user account name to be queried ECHO. ECHO Note: This batch file uses DSGET and DSQUERY (native in Windows ECHO Server 2003, will work in Windows 2000 and XP if available). ECHO. ECHO Written by Rob van der Woude ECHO http://www.robvanderwoude.com