Tuesday, 6 January 2009

Using PSExec to Remotely install software

Believe it or not I got asked what can I use to deploy software, and I said well the list is endless but the question is really are you doing it as a one off or as a weekly thing?

turns out guy just wanted to patch some server after finding there was a problem with one HBA card.

So I said what version of windows or linux he said typically windows, so first thing came to mind sysinternals tool I love psexec works for me so well I try to use it daily, what I like so much about its that its simple command line no GUI or dependency services.

So for those of you in a lost as to what I'm talking about here its is.
goto microsoft.com or google and type in sysinternals you'll end up on a technet page where the sysinternals software has been relocated to now since microsoft took it over, they have some lovely tools but the one I like best is psexec it lets you run remote command like a remote command line.

Example
for /f %i in (c:\serverlist1.txt) do psexec -c -d \\%i Win2003SP3.exe /quiet /norestart /overwriteoem

in this example the list has just a basic text "serverlist1" with a server on each line or IP the psexec to start the process and then -c says to copy the file to the machine, and -d so it doesn't wait for the program to complete.

another example is the one I use for patching SQL
for /f %i in (c:\list1.txt) do psexec -c -d \\%i c:\SQLSERVER2005SP2-KB921896-x86-ENU.exe /allinstances /quiet

but you can use this with many patches as well example, I created a install.bat file and ran that to deploy many patches to each server the content of the batch file is as follows.

net use X: \\server\share\
@echo off
setlocal
set PATHTOFIXES=x:\update

%PATHTOFIXES%\WindowsXP-KB######-x86-LLL.exe /quiet /norestart
%PATHTOFIXES%\WindowsXP-KB######-x86-LLL.exe /quiet /norestart
%PATHTOFIXES%\WindowsXP-KB######-x86-LLL.exe /quiet /norestart

net use x: /d


Then I execute this batch file on many servers.
for /f %i in (c:\list1.txt) do psexec -c -d \\%i c:\install.bat

This is how I have install application and service packs on many servers.

1 comments:

Moriett said...

great post...
alternative without "for" loop:
psexec \\@list1.txt ....
(in wmic is /node:@clients.txt too)