Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I would like to run a basic command on multiple servers by using a response file, similar to your How to ping multiple servers and return their IPs command. I can run the command from my workstation and it returns all of the information just fine.

schtasks /query /v /fo csv /nh >> \\my-pc\c$\temp\details_sched_tasks.csv
share|improve this question

migrated from stackoverflow.com May 9 '11 at 17:17

This question came from our site for professional and enthusiast programmers.

    
have you tried an automated ssh query? –  MaQleod May 9 '11 at 18:06

3 Answers 3

up vote 0 down vote accepted

This option worked best.

Detailed Views of Scheduled Tasks

  • Create a file named server_list.txt and supply all the names of the servers you wish to run the command against.
  • Log onto a server in the domain you wish to run the command against.
  • Place the file into a directory like d:\temp or even just the root of d:\
  • Open a command prompt and go to the same directory you have your list of servers.
  • Copy/paste the below command into the command window and hit enter.

for /f %x in (server_list.txt) do (schtasks /query /s %x /v /fo csv /nh >> d:\sched d:\sched_tasks.csv)

share|improve this answer

PSExec supports a text list of computer names or IPs as an argument.

Example:

psexec /u domain\adminguy @computerlist.txt \\server\share\command_to_run.bat
share|improve this answer

Could port your servers to a list using dsquery, then use psexec to execute the schtask on the remote computer using the output. It would look something like this.

dsquery computer ou=serverOU,dc=microsoft,dc=com* -o rdn > list.txt

FOR /F "tokens=1 delims=" %%a in ('type list.txt') DO psexec \\%%a schtasks /query /v /fo csv /nh >> \\my-pc\c$\temp\details_sched_tasks.csv
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.