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
61 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
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 
LVL 24

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

Are your end users making ugly email signatures?

Have you left it up to your end users to create their own email signatures? Are they forgetting to add the company logo or using garish font colors? Take control and ensure all users have the same email signature.

Question has a verified solution.

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

Sometimes drives fill up and we don't know why.  If you don't understand the best way to use the tools available, you may end up being stumped as to why your drive says it's not full when you have no space left!  Here's how you can find out...
A procedure for exporting installed hotfix details of remote computers using powershell
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 the steps necessary to join and promote the first Windows Server 2012 domain controller into an Active Directory environment running on Windows Server 2008. Determine the location of the FSMO roles by lo…

920 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

11 Experts available now in Live!

Get 1:1 Help Now