A Quick Tip To Check Schedule Tasks On Remote Computers

You have created a schedule task using the Group Policy on all the domain client computers or servers. You need to verify to make sure this Task has been created on all the computers. Let's say the Task name is BatchJob. Group Policy does not provide reporting. You need to use the below mentioned script to accomplish this:

Steps:

  • Create a text file and name it as CompList.TXT
  • Put all the computer or Server names in it.
  • Next, put the following lines in a file as it as CheckTasks.CMD
  • REM ***START HERE***
  • @ Echo Off
  • SETLOCAL EnableDelayedExpansion
  • Echo Computer Name, Task Created or Not? >> Result.CSV 
  • FOR /F "Tokens=*" %%L IN (CompList.TXT) DO (
  •    SET CompName=
  •    SET CompName=%%L
  •    Psexec.exe \\!CompName! C:\Windows\System32\Schtasks.exe /query > OutPut.txt
  •    Find /i "BatchJob" < OutPut.txt
  •    IF !ErrorLevel! == 0 (
  •        Echo !CompName!, Yes >> Result.CSV
  •    ) ELSE (
  •        Echo !CompName!, No >> Result.CSV
  •    )
  • )
  • REM ***END HERE***

The script runs against each server or computer mentioned in the CompList.TXT. It runs Schtasks.exe command with the help of Psexec.exe to execute it remotely and output is gathered in the OutPut.txt. Next command searches for BatchJob in the output.Txt. The end result is stored in a CSV file called Result.CSV.

Download Psexec.exe from here:

http://technet.microsoft.com/en-us/sysinternals/bb897553.aspx

About The Author

1 thought on “A Quick Tip To Check Schedule Tasks On Remote Computers”

Leave a Comment

Your email address will not be published. Required fields are marked *

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Scroll to Top