Use Excel to create easy batch jobs

25 08 2009

Do you have to run a command on several servers remotely?  You can enter each command separately, but every good admin should know how to make life easier for him/her self.  For example, I wanted to use the psloggedon.exe tool to find out who was logged in to all the servers I manage (about 150).  Naturally, I could log into each server, check the Terminal Server Manager, and go on the next, but who wants to do that? 

The PSTool – psloggedon.exe is a nice little utility that I can run from my command prompt, and have it query a remote computer, returning who is logged on to that server.  So, starting in Excel (I already had a list of all the servers), I pasted the list of servers in the C column.

Next, in Column A, I entered “psloggedon.exe” – the name of the executable I want to run.  in Column B, I put a “ \\” – note the space in front of the \\.  In column E, I entered my first switch, “ –l” – and in column F, a second switch “ –x” again, note the spaces before the switches.

 image image

Now, to bring the whole thing together.  I LOVE the command Concatenate. 

image

In column G, I entered =concatenate(A1,B1,C1,D1,E1)

image

This will combine all the columns together (now you know why the spaces were above) for your final command.

image

You can now select column G, and copy and paste it into notepad, and save it as a .bat file.  You now have an easily made bat file, using Excel.








Design a site like this with WordPress.com
Get started