Asked by:
Install an msi silently within a Powershell Script

Question
-
Hi All
I'm trying to install an msi silently within a powershell script using the following command: $install is
defined in the script to point at the installation path.msi file.start-process "msiexec.exe" -arg "/i $install /qn" -Wait
Doesn't matter what I do when I run the full script everything works fine except this 1 line and it brings up
the following screen.I have tried everything to get it working but nothing works, I need some help please
Regards
- Edited by Stewart.N Thursday, December 24, 2015 3:33 AM
- Moved by Bill_Stewart Friday, January 29, 2016 3:53 PM Abandoned
Thursday, December 24, 2015 3:29 AM
All replies
-
Just run the MSI file.
c:\folder\something.msi /quiet
Not all MSI files can be run without user interaction. Contact the vendor for instructions.
\_(ツ)_/
Thursday, December 24, 2015 5:13 AM -
this is a powershell script that im using through SCCM2012 to deploy Global Protect VPN.Thursday, December 24, 2015 5:25 AM
-
So? That works in any PowerShell script.
Start at a PS prompt and type the command until you figure out how it works. Any installer that requires an input will not run silently and will pop up a UI even if you use /quiet with a message. If you cannot make it work manually it will not work in a script.
\_(ツ)_/
Thursday, December 24, 2015 5:44 AM -
I can get it to run silently from a cmd prompt using the following:
msiexec.exe /i "<install path><file name>.msi " /qn
i have been trying using Powershell and nothing will work.
Thursday, December 24, 2015 5:49 AM -
try this
start-process "msiexec.exe" -arg "/i $([char]34 + $install + [char]34) /qn" -Wait
Thursday, December 24, 2015 5:53 AM -
You didn't show that you were using quotes:
$arglist=@( '/i', $install, '/qn' ) start-process msiexec.exe -ArgumentList $arglist -NoNewWindow
\_(ツ)_/
- Edited by jrv Thursday, December 24, 2015 6:02 AM
Thursday, December 24, 2015 6:01 AM -
You didn't show that you were using quotes:
$arglist=@( '/i', $install, '/qn' ) start-process msiexec.exe -ArgumentList $arglist -NoNewWindow
\_(ツ)_/
Hi There
Thanks for this, where do I put my $install command ?
Thursday, December 24, 2015 8:06 AM -
$install is already there. Just assign it. Do you know how to assign a variable?
\_(ツ)_/
Thursday, December 24, 2015 8:09 AM -
$install is already there. Just assign it. Do you know how to assign a variable?
\_(ツ)_/
Hi There
I'm new to powershell scripting but I have read up on the use of variables with scripts, sorry I should have looked closer to your reply
Thanks again
Thursday, December 24, 2015 9:35 AM -
Also - always read al of the help for any command you are using
help Start-Process -full
\_(ツ)_/
Thursday, December 24, 2015 9:37 AM -
Also - always read al of the help for any command you are using
help Start-Process -full
\_(ツ)_/
Hi There
So I copied your suggestion and I still get the same popup, here is the full script:
#PowerShell Script to copy files from SCCM to the local machine in to the following: C:\Windows\Software Install
#Next the script will uninstall the current version of Global Protect and delete the directory in Program files
#Reinstall the new version of global protect from the files copied in the first step and removes the installation files.
#Added gp.***.com to the portal properties in the registry.#Step 1: Uninstall Current Version Of Global Protect & Remove Program File Entry
$uninstall32 = gci "HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall" | foreach { gp $_.PSPath } | ? { $_ -match "GlobalProtect" } | select UninstallString
$uninstall64 = gci "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" | foreach { gp $_.PSPath } | ? { $_ -match "GlobalProtect" } | select UninstallString
$install = "C:\Windows\Software Install\GlobalProtect64-233.msi"
if ($uninstall64) {
$uninstall64 = $uninstall64.UninstallString -Replace "msiexec.exe","" -Replace "/I","" -Replace "/X",""
$uninstall64 = $uninstall64.Trim()
Write "Uninstalling..."
start-process "msiexec.exe" -arg "/X $uninstall64 /qn" -Wait
Remove-Item -path "C:\Program Files\Palo Alto Networks" -Recurse}
if ($uninstall32) {
$uninstall32 = $uninstall32.UninstallString -Replace "msiexec.exe","" -Replace "/I","" -Replace "/X",""
$uninstall32 = $uninstall32.Trim()
Write "Uninstalling..."
start-process "msiexec.exe" -arg "/X $uninstall32 /qn" -Wait
Remove-item -path "C:\Program Files (x86)\Palo Alto Networks" -Recurse}#Step 2: Reinstall GlobalProtect
Write "Installing..."
start-process "msiexec.exe" -arg "/i $install /qn" -Wait#Step 3: Add New Reg Key For Portal Information
Set-ItemProperty -Path "HKLM:\Software\Palo Alto Networks\GlobalProtect\PanSetup" -name Portal -value gp.***.com–Force#Step 4: Remove Installation Files
Remove-Item -path C:\Windows\Software Install -Recurse -Force- Edited by Stewart.N Thursday, December 24, 2015 11:13 AM
Thursday, December 24, 2015 11:12 AM -
You are grabbing an uninstall string and then adding extra switches to that. This is not any way like what you asked for.
You are not using the command the way I showed you so wht you are posting is of little use.
Start small. Figure out how to make each command work. Learn how to place trace commands I your scritp and how to use them to verify what I happening.
You are not getting a string from the registry. You are getting an object. YOu need to spend time learning how to get te actual value andnot the registry object. Again this is a whole new question.
\_(ツ)_/
Thursday, December 24, 2015 3:50 PM -
Your uninstall lines are using "$uninstall64" and "$uninstall32". YOU are assigning "$install" an never using it
If I have to guess I wuld say you copied this crit from somewhere and have been trying to figure out how to make it work for your issue. YOu have no PowerShell training and are guessing.
There is not way that this scritp ever worked as intended so it I suspect to begin with.
To get where you are going you are going to have to learn enough about the installer, the registr and PowerShell to be ble toask a clear question.
The original question you have asked here has been answered in at least three ways. All o them can be made to work by the rest of us but you are not using them in the correct context or the way you originally claimed to need them to work.
The easiest way to customize an uninstall from the registry is to use the package ID and call msiexec directly. Once you find the display name of the package you will have the package ID.
Since we do not have your system we cannot be of more help than to answer a well formed question. Understanding how to use this information in PowerShell on your system is up to you.
\_(ツ)_/
- Edited by jrv Thursday, December 24, 2015 4:47 PM
Thursday, December 24, 2015 4:44 PM -
This would install your app if yu did it the easy way.
#Step 2: Reinstall GlobalProtect Write "Installing..." $install='C:\Windows\Software Install\GlobalProtect64-233.msi' start-process $install -argumentList '/quiet' -Wait
MSI files are executable files. They do not require MSIExec. Once you understand how to make that work allby itself you will see why your methods are failing. If the vendor does not allo a silent install then you are out of luck.
To test this just run this at any PS prompt. DO NOT USE ISE. (note the single quotes.)
C:\Windows\'Software Install'\GlobalProtect64-233.msi /quiet
If this give you the same prompt then you need to contact the vendor to find out how to do a silent install if it is possible.
Also note that you should never place vendor files into the Windows folder. This can cause issues. Microsoft has made this clear and future versins of Windows will completely prevent this.
\_(ツ)_/
Thursday, December 24, 2015 5:03 PM