@ECHO OFF REM GetActiveUsers.cmd REM 20110726, v1. SET UNIXUTILS=I:\Tools\UnixUtils\usr\local\wbin SET TMPDIR=C:\Temp ECHO Getting a list of all user accounts %SYSTEMROOT%\system32\dsquery.exe user forestroot -o samid -limit 0|sort > "%TMPDIR%\users.txt" ECHO Getting a list of disabled user accounts %SYSTEMROOT%\system32\dsquery.exe user forestroot -disabled -o samid -limit 0|sort > "%TMPDIR%\disabled.txt" ECHO Comparing both lists to filter out the disabled users %UNIXUTILS%\comm.exe -3 "%TMPDIR%\disabled.txt" "%TMPDIR%\users.txt" > "%TMPDIR%\Enabled-%date%.txt" ECHO Displaying the end result in Notepad %SYSTEMROOT%\system32\notepad.exe "%TMPDIR%\Enabled-%date%.txt"