Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Question
Tuesday, January 10, 2017 4:33 PM
Lets say I run this line of code..
Start-Process 'C:\PowerShell\Blah Blah Blah Installer.msi' -Wait
Its my understanding that PowerShell will run the installer.msi but it will wait until its finished installing before moving to the next line.. Anyhow.. That installs fine - No problems.. The installer wizard appears so I add /quiet so I don't even see the wizard appear it just carries on with the install but id keep -Wait so it still waits before proceeding to the next line..
What im wanting to do from this line of script is for PowerShell to comeback and tell me how the installation went.. Primarily because I now have it on quiet mode so I wont see how its gone.. Does anyone know the best and simplest way to do this cause I've been trying all sorts of methods with limited success.. Although I doing research in methods, my understanding of such methods isn't the best in this area which could be why im having limited success. Any suggestions would be brilliant!
Thanks
All replies (7)
Wednesday, January 11, 2017 10:02 AM ✅Answered
If the installer states an invalid command line argument, than you're using an invalid command line argument.
I am using this way of running installations for SCCM for about 7 Years now and it works just as intended.
You might pay attention to this documentation MSI Command Line Options
Grüße - Best regards
PS:> (79,108,97,102|%{[char]$_})-join''
Tuesday, January 10, 2017 4:37 PM
msi file are not executables. You have to run MSIEXEC.exe and provide the msi file as a paramter like this:
msiexec.exe /i "your msi file here"
Grüße - Best regards
PS:> (79,108,97,102|%{[char]$_})-join''
Tuesday, January 10, 2017 4:49 PM
msi file are not executables. You have to run MSIEXEC.exe and provide the msi file as a paramter like this:
msiexec.exe /i "your msi file here"
Grüße - Best regards
PS:> (79,108,97,102|%{[char]$_})-join''
That provided same output as "Start-Process 'C:\PowerShell\Blah Blah Blah Installer.msi' " - It starts the install wizard.. I mean I can add /passive or /quiet which then needs no user interaction but what im after is PowerShell to come back to me and say something like 'Yep, that's installed fine' or 'There was an issue with installation' - Sorry for being a pain
Tuesday, January 10, 2017 5:02 PM | 1 vote
Usually msiexec comes back with an exit code. You just have to catch this and act accordingly.
$Result = (Start-Process -FilePath "msiexec.exe" -ArgumentList "/i 'your msi file' /qb-!" -Wait -Passthru).ExitCode
Now you have your exit code in the variable $Result and you can deal with it.
Grüße - Best regards
PS:> (79,108,97,102|%{[char]$_})-join''
Tuesday, January 10, 2017 5:02 PM | 1 vote
Here you go...
http://stackoverflow.com/questions/4124409/run-msiexec-from-powershell-and-get-return-code
Hope it helps!
Tuesday, January 10, 2017 5:14 PM
MSI files cannot be waited on. They just tell the system installer to accept an installation database and process it. Multi-part installation files are very hard to manage.
\(ツ)_/
Wednesday, January 11, 2017 9:55 AM
Usually msiexec comes back with an exit code. You just have to catch this and act accordingly.
$Result = (Start-Process -FilePath "msiexec.exe" -ArgumentList "/i 'your msi file' /qb-!" -Wait -Passthru).ExitCode
Now you have your exit code in the variable $Result and you can deal with it.
Hi Guys, I've tried that line of code which is very similar to the line from http://stackoverflow.com/questions/4124409/run-msiexec-from-powershell-and-get-return-code and I get the exit code - 1639 which represents and I quote " Invalid command line argument. Consult the Windows Installer SDK for detailed command-line help."
I then decided to try -
(Start-Process 'C:\PowerShell\BlahBlahBlah Installer.msi' -Wait -PassThru).ExitCode
This brings up the installer and upon installation returns the exit code 0 which represents "The action completed successfully" which is brilliant.. I also put it on passive or quiet to reduce user interaction.. Only thing is once ive ran it and it installs and I try it again it provides the change, repair and remove wizard which upon that point I was hoping the exit code would differ to inform me the installation couldn't be completed but it still provides the exit code which kind of ties in with what JRV was saying about "They just tell the system installer to accept an installation database and process it." Which it seems to do and then spits out the 0 exit code cause its starting the installer but its not following it to the end because "MSI files cannot be waited on"
But.. If I cancel the installation wizard it spits out exit code 1602 which represents** "The user cancels installation."**
I might try the 'Try, catch and finally method' - Ill keep you guys posted with my progress
Apologies about the long response - Any Ideas?
Thnaks