JSI Tip 5712. Generate a CSV file of scheduled tasks and their credentials.

Using JT.EXE, I scripted Credentials.bat, to generate a CSV file of the scheduled tasks on any Windows 2000, Windows XP, and Windows .NET Server computer. The CSV file contains:

"\\ComputerName","Credentials","JobName".

The syntax for using Credentials.bat is:

Credentials ComputerName ReportFile

where:

ComputerName is the NetBIOS computer name, without leading \\.

ReportFile is the path to the output CSV file.

Credentials.bat contains:

@echo off
if \{%2\}==\{\} goto syntax
if not exist \\%1\c$ goto syntax
if not exist %~DP2 goto syntax
setlocal
set server=%1
set server="\\%server:"=%"
set report=%2
if exist %report% del /q %report%
if exist %tmp%\Credentials.tmp del /q %tmp%\Credentials.tmp
for /f "Tokens=*" %%a in ('jt /sm %server% /se p') do set line1=%%a&call :parse1
if exist %tmp%\Credentials.tmp sort %tmp%\Credentials.tmp /o %report%
if exist %tmp%\Credentials.tmp del /q %tmp%\Credentials.tmp
endlocal
goto :EOF
:syntax
@echo Syntax: Credentials ComputerName ReportFile
goto :EOF
:parse1
set line1=%line1:"=%
if not "%line1:~0,22%" EQU "\[TRACE\] Activating job" goto :EOF
set job=%line1:~24,99%
set job=%job:.job'=%
for /f "Tokens=*" %%b in ('jt /sm %server% /sac "%job%" /gc') do set line2=%%b&call :parse2 
goto :EOF
:parse2
set line2=%line2:"=%
if not "%line2:~0,9%" EQU "\[TRACE\] C" goto :EOF
set cred=%line2:~35,99%
set cred=%cred:'=%
@echo %server%,"%cred%","%job%">>%tmp%\Credentials.tmp


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