Skip navigation

JSI Tip 1245. Create a report of disabled accounts.


If you need a report of disabled accounts in your domains, run (on your PDC):

JSINActive <Drive:>\Folder\NotActive.txt

where <Drive:>\Folder\NotActive.txt is the output report file.

JSINActive.bat uses only standard commands and contains:

@echo off
if NOT "%1"

"" goto begin :syntax @echo Syntax: JSINActive File goto end :begin setlocal set file=%1 if exist %file% del /q %file% for /f "Skip=4 Tokens=*" %%i in ('net users') do call :parse "%%i" endlocal goto end :parse set str=#%1# set str=%str:#"=% set str=%str:"#=% if "%str%"

"The command completed successfully." goto end set substr=%str:~0,25%# set substr=%substr: =% set substr=%substr: #=% set substr=%substr:#=% if "%substr%"

"" goto end set /a cnt=0 for /f "Tokens=*" %%i in ('net user "%substr%"') do call :parse1 "%%i" set substr=%str:~25,25%# set substr=%substr: =% set substr=%substr: #=% set substr=%substr:#=% if "%substr%"

"" goto end set /a cnt=0 for /f "Tokens=*" %%i in ('net user "%substr%"') do call :parse1 "%%i" set substr=%str:~50,25%# set substr=%substr: =% set substr=%substr: #=% set substr=%substr:#=% if "%substr%"

"" goto end set /a cnt=0 for /f "Tokens=*" %%i in ('net user "%substr%"') do call :parse1 "%%i" goto end :parse1 set /a cnt=%cnt% + 1 set ustr=%1 if %ustr%

"The command completed successfully." goto end set ustr=%ustr:"=% if %cnt% EQU 2 set fullname=%ustr:~29,99% if %cnt% NEQ 6 goto end set ls="%ustr:~29,2%" if /i not %ls%=="No" goto end set substr=%substr:"=% set substr=%substr% # set substr=%substr:~0,22% set fullname=%fullname:"=% set fullname=%fullname% # set fullname=%fullname:~0,30% @echo %substr% %fullname% >> %file% :end

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