Partilhar via


Finding Scheduled Tasks Configured with Disabled Accounts

One of my customers has undergone a great deal of turnover in the past few weeks on the System Administration team.  We discovered that a number of Scheduled Tasks configured on the servers were configured with the accounts of admnistrators (instead of service accounts!).  The accounts were disabled when the admins left the organization and the Scheduled Tasks stopped working.  We needed to find all the Scheduled Tasks configured with admin accounts instead of service accounts on the servers.

The simpe batch file below uses the SCHTASKS utility to dump the configuration information from each server listed in a SERVERS.TXT file and dump the output to a file named SCHED_TASKS_CONFIG.TXT.

<<<------------------------------BEGIN BATCH FILE------------------------- >>>

:: NAME: SCHED_TASK_ACCT.CMD v1.0
:: DATE: 1/13/2009
:: PURPOSE:  TO dump the configuration of scheduled tasks on a server to a text file
::           so tasks configured with disabled accounts can be located.

ECHO %DATE% > SCHED_TASKS_CONFIG.TXT
ECHO %TIME% >> SCHED_TASKS_CONFIG.TXT
ECHO %USERNAME% >> SCHED_TASKS_CONFIG.TXT
ECHO. >> SCHED_TASKS_CONFIG.TXT
FOR /F "tokens=1" %%i in (servers.txt) DO schtasks /query /s %%i /v /fo list >> SCHED_TASKS_CONFIG.TXT 

<<<------------------------------END BATCH FILE------------------------- >>>

Comments