?
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
Medium Priority
?
139 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 25

Accepted Solution

by:
NVIT earned 1000 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 25

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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 25

Assisted Solution

by:Coralon
Coralon earned 1000 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 25

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

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

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

Possible fixes for Windows 7 and Windows Server 2008 updating problem. Solutions mentioned are from Microsoft themselves. I started a case with them from our Microsoft Silver Partner option to open a case and get direct support from Microsoft. If s…
An article on effective troubleshooting
This tutorial will show how to push an installation of Backup Exec to an additional server in both 2012 and 2014 versions of the software. Click on the Backup Exec button in the upper left corner. From here, select Installation and Licensing, then I…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Suggested Courses

771 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