• RSS
  • Twitter
  • FaceBook

A Quick Tip To Check Schedule Tasks On Remote Computers

  • Section(s): Administrator, Admin , Admin
  • Published on Dec 15, 2010.
  • Last Modified on Oct 31, 2009.
  • Last Modified by Nirmal Sharma.
  • Rating: Not Rated
This article explains how you can use Schtasks.exe with Psexec.exe 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 Nirmal Sharma

Nirmal is a Microsoft MVP in Directory Services and working as a Technical Architect/Consultant. He has been involved in Microsoft Technologies since 1994 and followed the progression of Microsoft Operating Systems and software. He is specialized in Directory Services, Microsoft Clustering, SQL, MOM, Exchange and Citrix. In his spare time, he likes to help others and write "internal" technical articles, white papers and tips on various Microsoft technologies. You can contact him at nirmal_sharma@mvps.org.


Article not looking right or info is missing? Let us know so that we can fix it: .


Receive all the latest articles by email!

Receive Real-Time & Monthly WindowsNetworking.com article updates in your mailbox. Enter your email below!
Click for Real-Time sample & Monthly sample

Become a WindowsNetworking.com member!

Discuss your network issues with thousands of other network administrators. Click here to join!

Community Area

Log in | Register

Readers' Choice

Which is your preferred data recovery solution?