• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 239
  • Last Modified:

Need to have PSEXEC or .bat script return a log file (.txt) after deploying an MSI to remote machines

I am currently deploying a plugin (.MSI) to remote machines using PSEXEC to call a script. Each time I deploy  via PSEXEC, I get a bunch of "Process ID" result. It is hard to tell if the deployment was successful or not. Logging is enabled on the script (attached) to where I can see logs for each machine that I deploy to. However, it is not feasible to go into each machine to look at logs. Can someone please help modify the .bat file script to produce a log (.txt) that will tell me if the deployment was successful on the remote machines I deploy to? I'd like a txt file to be produced on the desktop of the server I am executing psexec from (e.g. - Server1). I want the convenient of just looking at the txt file that will show me which machines failed so I can keep track of it.  

PSEXEC commands from Server1:
2016-07-26_15-46-00.png
.BAT script is attached, but for the purpose of this thread, i changed it to .txt.
Mimecastdeploy_OUTL2013_x64.txt
0
joukiejouk
Asked:
joukiejouk
  • 3
  • 2
2 Solutions
 
NVITCommented:
This will returns the psexec results.

- Run it in the CMD window.
- Put everything on one line.

for /f %a in (c:\hostnames.txt) do @echo %a---------- >> c:\psresults.txt
  & psexec \\%a -h -u username -d cmd /c mimecastdeploy_outl2013_x64.bat >> c:\psdetails.txt 2>&1 
  && echo Success >> c:\psresults.txt || echo Failed >> c:\results.txt

Open in new window

0
 
joukiejoukAuthor Commented:
So I entered the command as such:
2016-07-27_15-10-09.png
I never got a prompt to enter my password. It does not appear to do anything as nothing return when I execute the command. Not sure if my commands are set correctly, but maybe you can tell.

I got into C:, and see that the psdetails.txt and psresults.txt do generate.
2016-07-27_15-11-25.png
I open psdetail.txt, and this is what I get:
2016-07-27_15-12-22.png
I open psresult.txt, and this is what I get:
2016-07-27_15-12-32.png
As a result, the deployment to the remote machines were not successful. Maybe you can pin point where I went wrong.
0
 
NVITCommented:
It's asking for your password. You have to enter it when it seems to hang, unless you use the -p switch with the password.
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
CoralonCommented:
I really don't think you'd need to add very much to it..

At the end of your Install section, you could check the result code and echo out Success or Failure into a result file on the server itself..

Now..as you mentioned, going to each machine would be a complete hassle..

So, at the end of that, you just run another batch file to sweep them all to your local machine, and then look at it..

>>"%LogFile%" echo [%Date%][%Time%] Starting installation.
msiexec.exe /i "%Msi%" /qn /liewa+ "%LogFile%"

if %ERRORLEVEL% == 0 echo %COMPUTERNAME%,SUCCESS,ERROR 0 > %systemroot%\temp\OlkResults.txt" & goto CONTINUE
if %ERRORLEVEL% == 3010 echo %COMPUTERNAME%,SUCCESS - REBOOT, ERROR 3010 > %systemroot%\temp\OlkResults.txt" & goto CONTINUE
if %ERRORLEVEL% GTR 0 echo %COMPUTERNAME%,FAILURE,ERROR %ERRORLEVEL% > %systemroot%\temp\OlkResults.txt" 

:CONTINUE
[code]

After your PSEXEC deployments are complete (assuming a list)

for /f %%f (servers.txt) do for /f "tokens=1,2,3 delims=," %%A in (\\%%f\c$\windows\temp\OlkResults.txt) do if %%B == FAILURE (copy \\%%f\c$\windows\temp\OlkResults.txt "%temp%\%%A_FailedInstall.txt) else ( copy \\%%f\c$\windows\temp\OlkResults.txt "%temp%\%%A_SuccessfulInstall.txt")

Open in new window



Coralon
0
 
NVITCommented:
joukiejouk,

Correction: In my last post, all references to c:\results.txt should be c:\psresults.txt
0
 
joukiejoukAuthor Commented:
I never got a chance to re-visit the script option to set logging. Anyhoot, the deployment has been completed so I am not gong to worry about it. Thanks for the response.
0

Featured Post

Transaction-level recovery for Oracle database

Veeam Explore for Oracle delivers low RTOs and RPOs with agentless transaction log backup and transaction-level recovery of Oracle databases. You can restore the database to a precise point in time, even to a specific transaction.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now