1

In my powershell script, I need to run couple of msiexec commands quietly. The problem is when I try to run the command, the Windows Installer help popup shows rather than executing the command. (Below Image)

enter image description here

The same command runs well in cmd. Below is my command. I have kept the & in the command in double quotes to consider it as a string as suggested.

& msiexec /log c:\msxml.log /quiet /I "&" D:\LoadGeneratorsetup\prerequisites\msxml6\msxml6_x64.msi

I tried using Start-Process -FilePath to run this but end up with the below error.

Start-Process : A positional parameter cannot be found that accepts argument 'c:\msxml.log'.
At line:1 char:1
+ Start-Process -FilePath msiexec /log c:\msxml.log /quiet /I "&" D:\Lo ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [Start-Process], ParameterBindingException
    + FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.StartProcessCommand

Can someone provide an details on how to execute the command quietly using powershell.

4
  • 1
    Just get rid of the "&" and the & at the start so :: msiexec /log c:\msxml.log /quiet /I D:\LoadGeneratorsetup\prerequisites\msxml6\msxml6_x64.msi Commented Jun 5, 2018 at 6:51
  • Thanks Owain. it worked after removing both the &. But one last msiexec is stilling giving the Windows Installer popup. The command looks like below - & msiexec /i "& D:\LoadGeneratorsetup\HP_LoadGenerator.msi" /qb /l*vx "& D:\LoadGeneratorsetup\Logs\InstallationLogs"+"_"+(Get-Date -Format "yyyy-MM-dd-hh-mm-s")+".txt" i tried removing all the & but still the same. can you help me here. Commented Jun 5, 2018 at 7:12
  • Check my answer Commented Jun 5, 2018 at 7:25
  • Please see my answer below for some links to the Windows Installer PowerShell Module. Commented Jun 5, 2018 at 9:48

2 Answers 2

1

For your second command:

& msiexec /i "& D:\LoadGeneratorsetup\HP_LoadGenerator.msi" /qb /l*vx "& D:\LoadGeneratorsetup\Logs\InstallationLogs"+"_"+(Get-Date -Format "yyyy-MM-dd-hh-mm-s")+".txt"

You have two options, either set the log path to a variable or just bracket the path:

1 - Set to variable

$logfile = "D:\LoadGeneratorsetup\Logs\InstallationLogs" + "_" + (Get-Date -Format "yyyy-MM-dd-hh-mm-s") + ".txt"
msiexec /i "D:\LoadGeneratorsetup\HP_LoadGenerator.msi" /qb /l*vx $logfile

2 - Bracket the path

msiexec /i "D:\LoadGeneratorsetup\HP_LoadGenerator.msi" /qb /l*vx ("D:\LoadGeneratorsetup\Logs\InstallationLogs" + "_" + (Get-Date -Format "yyyy-MM-dd-hh-mm-s") + ".txt")

I am assuming that the command is just not evaluating the log path before running the command.

Sign up to request clarification or add additional context in comments.

2 Comments

Yes, you are right. I just tried just giving a static file name and it worked. Thanks for the help Owain. I'll use any of the above option and set the file name.
Owain - one query - the command & D:\LoadGeneratorsetup\prerequisites\vc2005sp1_mfc_security_update_x86\vcredist_x86.exe /q:a /c:"msiexec /i vcredist.msi /qn"" " is getting executed without any errors but it's not getting installed. When i run the same in cmd, its executing and installing. is the msiexec in the command making it to not execute in PS ? please clarify.
0

I want to alert you to the Windows Installer PowerShell Module on github.com. Scroll down on this front page for description and some samples, see releases tab for download. I haven't really tested it much, but it is from Heath Stewart - Microsoft Senior Software Engineer (github).

Brief, inline sample:

install-msiproduct .\example.msi -destination (join-path $env:ProgramFiles Example)

Some Additional Links:

5 Comments

thanks, will look into it. if you can help me on this command.. D:\LoadGeneratorsetup\prerequisites\vc2005sp1_mfc_security_update_x86\vcredist_x86.exe /q:a /c:"msiexec /i vcredist.msi /qn"" " is perfectly working in cmd but not in powershell. i have a similar command (2008 inplace of 2005 in the command) which is running fine both in cmd and PS. not sure what am i missing here.
Not familiar with this, but why don't you run vcredist_x86.exe directly in silent mode as explained when you do vcredist_x86.exe /? and get the command line options? Not sure you need to deal with the MSI at all.
I tried with D:\LoadGeneratorsetup\prerequisites\vc2005sp1_mfc_security_update_x86\vcredist_x86.exe /quiet /norestart but it says "command line option syntax error" so it is looking for parameters
Sorry, can't investigate this right now. Maybe have a quick look at this.
Great. The convention is to create a new question for largely unrelated "follow-up" questions - maybe consider that for the future - there is a lot of moderation here on SO. Glad that simple link helped though!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.