Roberto Alves

Scripting and server based computing

Easily running commands in all servers/workstations

Sometimes we are diving into so many tools, products, technologies, etc that we forgot simple and old tools that can save the day or at least save a good time. I will give as example the Sysinternals psexec, that is very useful to run remote commands.

Let’s imagine that you need force a policy update in all servers or workstations. May be, your first thought can be:  “I can create a script that reads a file with a list of servers/workstations, after read the file, the script can run processes using a WScript.Shell object. After ran the process in each server the script can get a result and save a file with the task results.” Of course that this script will take some time to write and probably will have some dozens of code lines.

Or, you can do the same task just with one line of command.

psexec @servers.txt c:windowssystem32gpupdate.exe /force > result.txt

Yes! Psexec can read a text file with a list of machines and run the command in all machines, simplifying your life and to save the results, you can use our  old ms-dos technique: “>”

Additionally, Psexec offers other some great features like run the process interacting with the machine desktop, or timeouts between each machine, or run as System, or even define what processor you want to run the process.

Category: Scripts

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