Solved

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

Posted on 2016-07-26
6
55 Views
Last Modified: 2016-08-04
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
Comment
Question by:joukiejouk
  • 3
  • 2
6 Comments
 
LVL 23

Accepted Solution

by:
NVIT earned 250 total points
ID: 41731945
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
 

Author Comment

by:joukiejouk
ID: 41732106
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
 
LVL 23

Expert Comment

by:NVIT
ID: 41732158
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
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
LVL 23

Assisted Solution

by:Coralon
Coralon earned 250 total points
ID: 41732282
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
 
LVL 23

Expert Comment

by:NVIT
ID: 41732444
joukiejouk,

Correction: In my last post, all references to c:\results.txt should be c:\psresults.txt
0
 

Author Closing Comment

by:joukiejouk
ID: 41743150
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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

New Windows 7 Installations take days for Windows-Updates to show up and install. This can easily be fixed. I have finally decided to write an article because this seems to get asked several times a day lately. This Article and the Links apply to…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This tutorial will give a short introduction and overview of Backup Exec 2012 and how to navigate and perform basic functions. Click on the Backup Exec button in the upper left corner. From here, are global settings for the application such as conne…
This tutorial will walk an individual through locating and launching the BEUtility application to properly change the service account username and\or password in situation where it may be necessary or where the password has been inadvertently change…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now