Anonymous
public text v1 · immutable@echo off
setlocal
for /f "tokens=*" %%a in ('dsquery user -name *') do call :DSGET %%a
endlocal
goto :EOF
:DSGET
set counter=0
set DN=%1
for /f "tokens=*" %%a in ('dsget user %1 -display') do call :DSGET2 %%a
set DN=
goto :eof
:DSGET2
set /a counter=%counter% + 1
if {%counter%}=={2} echo %DN% has displayname: %1
goto :eof