System Administrators would want to run some simple scripts in multiple computers. Microsoft has some great tools to ease the job, PsTools bundle is really powerful easy tool.

PsExec can be used to run scripts on remote computers.

Below is a simple example to find uptime of multiple systems and dumping to a file.

  •  Enter the system names in a notepad and save as a batch file (eg. mc.bat)
  • Have a script written and save it as a batch file “uptime.bat”. (systeminfo | find “Up Time” >> \\<Server share>\uptime.txt)
  • Now use psexec to run it. Ensure you are in the directory where the tool is. Also ensure admin share is enabled in the remote systems. Below command will run the uptime script in the systems mentioned in mc.bat file

psexec @mc.bat -u “username” -p “password” /c “path to script”

  • To execute in a single remote system, below is the command

psexec \\<ip> -u “username” -p “password” /c “path to script”

Just makes our task easier. We can do  lots with this. Have it downloaded and explored in the below link,

http://technet.microsoft.com/en-us/sysinternals/bb896649.aspx

Enjoy Scripting!

Tagged with:
 
  • Rahul

    i have a batch file as below

    @echo off
    set mydate=%date:~7,2%:%date:~4,2%:%date:~-4%
    set mytime=%time:~0,2%:%time:~3,2%:%time:~6,2%
    echo %mydate%,%mytime% >> E:SERVER_HEALTH_CHECKupt.txt
    systeminfo /s CHRS01 | findstr “Host Time:” >> E:SERVER_HEALTHupt.txt
    systeminfo /s CHRS02 | findstr “Host Time:” >> E:SERVER_HEALTHupt.txt
    exit

    It is giving output like

    0,14:02:2014,12:12:31
    Host Name: CHRS01
    System Up Time: 97 Days, 10 Hours, 47 Minutes, 13 Seconds
    Host Name: CHRS02
    System Up Time: 97 Days, 10 Hours, 47 Minutes, 13 Seconds

    But i want output like

    CHRS01 ,25:12:13:10:40:01,97 Days, 10 Hours, 47 Minutes, 13 Seconds
    CHRS02 ,25:12:13:10:40:03,97 Days, 10 Hours, 47 Minutes, 13 Seconds

    Is anybody help me on this…..????

Set your Twitter account name in your settings to use the TwitterBar Section.
%d bloggers like this:
Bitnami