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
110 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 24

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 24

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
Turn Insights into Action

Communication across every corner of your business is essential to increase the velocity of your application delivery and support pipeline. Automate, standardize, and contextualize your communication processes with xMatters.

 
LVL 25

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 24

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

Edgartown IT Case Study

Learn about Edgartown's quest to ensure the safety and security of the entire town's employee and citizen data. Read the case study!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
Resolving an irritating Remote Desktop connection that stops your saved credentials from being used.
This tutorial will walk an individual through the steps necessary to configure their installation of BackupExec 2012 to use network shared disk space. Verify that the path to the shared storage is valid and that data can be written to that location:…
This tutorial will show how to configure a new Backup Exec 2012 server and move an existing database to that server with the use of the BEUtility. Install Backup Exec 2012 on the new server and apply all of the latest hotfixes and service packs. The…

717 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