Wednesday, June 8, 2011

Finding Out a Machines Uptime

The title says all - being curious, I wanted to find out everyone's machine uptime. In other words, how long has the computer been powered on?

You need:
-psexec
-elevated privileges to access remote machines
-grep - if you want to filter out what you dont need from the command, add ".../bin" directory to your environment variables

If you run "systeminfo" from the command prompt on your machine, this is the output that we are looking for from remote machines. Also, we just need this line from the output: "System Boot Time: 6/8/2011, 7:07:01 AM" The other junk can be handy for other "curiousness'" but for this instance, Im not interested.

Create a separate text file named machines.txt in the same directory. Put all your computer names in the text file, each on a separate line. Ok, open the command prompt, adjust your screen buffer, run the .cmd file. If you have hundreds of computers, this will take a LONG time to run.

I believe there is a way to output the results in a local text file, but I could never get it to work since I have a pipe grep at the end, however I could be doing something wrong.