Skip navigation

JSI Tip 7262. How many users exist in your domain?

If you need to count the number of users in your domain, run NumberOfUsers.bat from your workstation.

NumberOfUsers.bat contains:

@echo off
setlocal
set /a numb=0
for /f "Skip=4 Tokens=*" %%i in ('net user /domain^|findstr /v /c:"----"^|findstr /v /i /c:"The command completed"') do (
 set line=%%i
 call :parse
)
@echo Number of users=%numb%
endlocal
goto :EOF
:parse
set name=%line:~0,25%
set /a numb=%numb% + 1
set name=%line:~25,25%
if not "%name%" EQU "" set /a numb=%numb% + 1
set name=%line:~50,25%
if not "%name%" EQU "" set /a numb=%numb% + 1



Hide comments

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.
Publish