I have scripted GetUsers.bat to return all the user names in your domain in a script.

The syntax for using GetUsers.bat is:

\[call\] GetUsers

The output is displayed on the console, so you could pipe it to a file, or use it for subsequent processing, as in the following trivial examples:

:: Display all user names in alphabetical order
for /f "Tokens=*" %%u in ('getusers') do (
 @echo %%u
)


:: Display all user names that contain a <b>Z</b>, in any position, in any case, in alphabetical order
for /f "Tokens=*" %%u in ('getusers^|findstr /i /c:"Z"') do (
 @echo %%u
)


:: Display all user names with their Distinguished Name, using <a href="/article/jsifaq/jsi-tip-7335-how-do-i-retrieve-the-distinguished-name-of-a-user-.aspx"><b>GetDN</b></a>
@echo off
setlocal ENABLEDELAYEDEXPANSION
for /f "Tokens=*" %%u in ('getusers') do (
 call GetDN "%%u" DN
 @echo "%%u" !DN!
)
endlocal
GetUsers.bat contains:
@echo off
setlocal
<font size="1">for /f "Skip=2 Tokens=*" %%i in ('net user /domain^|findstr /v /c:"User accounts for "^|findstr /v /c:"----"^|findstr /v /i /c:"The command completed"') do (</font>
 set line=%%i
 call :parse
)
endlocal
goto :EOF
:strip
set short=%name%#
set short=%short:  =%
set short=%short: #=#%
set short=%short:#=%
@echo %short%
goto :EOF
:parse
set name=%line:~0,25%
call :strip
set name=%line:~25,25%
if not "%name%" EQU "" call :strip
set name=%line:~50,25%
if not "%name%" EQU "" call :strip