Here i trying to install MSI package with argument in powershell where i have to pass few special characters as below:
$msi="/I mypkg.msi TARGETAPPPOOL='.NET v4.5 Classic' /L mai.log /qn"
Start-process "msiexec.exe" -ArgumentList $msi -wait -nonewwindow -PassThru
Showing "1639" error code - A command line option passed to the installer is invalid.
Installation working well with default value, if I remove "TARGETAPPPOOL='.NET v4.5 Classic'”
Can you please suggest how we can write it?
Thanks
Pass the arguments as an array like this:
$msi = '/I', 'mypkg.msi', 'TARGETAPPPOOL=".NET v4.5 Classic"', '/L', 'mai.log', '/qn'
Start-process "msiexec.exe" -ArgumentList $msi -wait -nonewwindow -PassThru
PowerShell automatically adds space separator between the arguments.
Related
I run this command in PowerShell
Start-Process -FilePath 'C:\Program Files\Typora\Typora.exe' -ArgumentList 'C:\Users\Administrator\Desktop\Hello world.md'
But Typora says
C:\User\Administrator\world.md does not exist
It looks like PowerShell executes
Start-Process -FilePath 'C:\Program Files\Typora\Typora.exe'
-ArgumentList 'C:\Users\Administrator\Desktop\Hello' 'world.md'
I want to escape the space but the single-quoted not working...
PowerShell version: 5.1.19041.610
PowerShell may not quote strings properly when calling external executables. See
Curl in PowerShell with custom cookie file
PowerShell or CMD errors on space in file path
So to fix this you need to pass the literal " to the exe file by escaping it properly
Start-Process -FilePath 'C:\Program Files\Typora\Typora.exe' `
-ArgumentList '"C:\Users\Administrator\Desktop\Hello world.md"'
Try adding ` to excape spaces in powershell:
Start-Process -FilePath 'C:\Program Files\Typora\Typora.exe' -ArgumentList 'C:\Users\Administrator\Desktop\Hello`world.md'
I am trying to automate the installation of gstreamer on windows using powershell
I have the msi file downloaded, and am installing it as shown below
PS C:\Users\Administrator> $path = "C:\Users\Administrator\Downloads\gstreamer-1.0-devel-mingw-x86_64-1.18.0.msi";
PS C:\Users\Administrator> Start-Process -Wait -FilePath $path -Argument "/qn"
However, this does not get me the complete installation, because it is only selecting the default arguments from the installer.
I need to specify for it to perform the complete installation, how can I modify my arguments? So that it selects "complete" installation and not "typical" like it does by default
These should work:
Start-Process -Wait -FilePath $path -Argument "/qn","Complete=1"
Start-Process -Wait -FilePath $path -Argument "/qn Complete=1"
I had the same problem, so I ran the Installer from power shell with and without the /qn argument and logged the process into two different files. Finally, I compared the result and I was able to find that for installing process using the UI it adds a property called INSTALLLEVEL, which is set to 1000 (don't know why this value yet). So, by adding the argument INSTALLLEVEL=1000 it installs the complete version.
Start-Process -Wait -FilePath gstreamer-1.0-mingw-x86_64-1.20.2.msi -Argument "/qn INSTALLLEVEL=1000"
I had tried below but it did not work
Start-Process -Wait -FilePath $path -Argument "/qn","Complete=1"
Start-Process -Wait -FilePath $path -Argument "/qn Complete=1"
While this is working fine for me.
Start-Process -Wait -FilePath gstreamer-1.0-mingw-x86_64-1.20.2.msi -Argument "/qn INSTALLLEVEL=1000"
I am trying to install the Tenable Nessus agent via PowerShell script and am running into no end of issues because the Nessus MSI syntax requires a mix of no quotes and double quotes. The problem I am running into is that PowerShell needs me to escape the double quotes which seems to break the syntax understood by msiexec.exe. Let me show you what I am doing and what I have tried. I am not a strong PowerShell person, and the solution is escapes me.
Here is the code block where I set the variable with all the MSI arguments. The Nessus syntax requires that all its configs be surrounded by double quotes except for NESSUS_KEY. Earlier in the script I define the other variables.
$MSI_Arguments = #(
"/i"
"$Install_File"
"NESSUS_KEY=$Nessus_Key"
"NESSUS_SERVER=""cloud.tenable.com:443"""
"NESSUS_NAME=""$FQDN"""
"NESSUS_GROUPS=""$Nessus_Group"""
# The colon in front of a variable needs special treatment ({}).
"NESSUS_PROXY_SERVER=""${Proxy_Server}:${Proxy_Port}"""
"NESSUS_OFFLINE_INSTALL=""yes"""
"/qn"
"/norestart"
"/L*v ""$LogPath\Tenable_MSI.log"""
)
I then try running the command like so. This command does not work properly - the install proceeds, but because the parameters in -ArgumentList needs to be surrounded by double quotes, it does not get all the parameters, resulting in a broken installation.
$MSI_Command = Start-Process -Wait -NoNewWindow -PassThru -FilePath "msiexec.exe" -ArgumentList $MSI_Arguments
When I put $MSI_Arguments in double quotes, I then break how PowerShell deals with the double quotes in the variable code block. I have tried the following, but none work.
$MSI_Command = Start-Process -Wait -NoNewWindow -PassThru -FilePath "msiexec.exe" -ArgumentList "$MSI_Arguments"
$MSI_Command = Start-Process -Wait -NoNewWindow -PassThru -FilePath "msiexec.exe" -ArgumentList "$$(MSI_Arguments)"
$MSI_Command = Start-Process -Wait -NoNewWindow -PassThru -FilePath "msiexec.exe" -ArgumentList "${MSI_Arguments}"
I have even tried just running the command straight-up, no variables, just to try and figure out the syntax. I tried two double quotes (similar to what I am trying in the variable code block) and it it works.
Start-Process -Wait -NoNewWindow -PassThru -FilePath "msiexec.exe" -ArgumentList "/i C:\temp\NessusAgent-7.7.0-x64.msi NESSUS_KEY= NESSUS_SERVER=""cloud.tenable.com:443"" NESSUS_NAME=""foo"" NESSUS_GROUPS=""bar"" NESSUS_PROXY_SERVER=""proxy.company.com:80"" NESSUS_OFFLINE_INSTALL=""yes"" /qn /norestart /L*v ""C:\temp\Tenable_MSI.log"""
Now that I have a working command, I cannot figure out how to modify the variable block to work. If I just add more doubled double quotes, I get errors. If I add "" I get errors. If I add " I get errors... I am so close, yet so far.
Please, rescue me from this hell I am in. At this point I am wondering if Passing double quotes through PowerShell + WinRM has the answer, and I should base64 encode the install string, but that may be beyond my skillset given how I use variables...
I am trying to install a rather oldish application. I am wanting to do it in powershell because I have post install functions that need to be done in powershell
The -argumentlist is not starting all the arguments after the /qn ( silent mode install )
The application starts and proceeds to install unattended in silent mode but ignores all the arguments after /qn. So its installing without any of the parameters I have specified. Is there anything I am doing wrong? Could just be my quotes are in the wrong places. My powershell knowledge is very very rusty
$workingDirectory = (split-path $myinvocation.mycommand.path -parent)
#Installs my application
Start-Process -Filepath "$workingDirectory\application.exe" -ArgumentList "/args /qn reboot=reallysuppress SILENT=yes INSTALLSTANDALONE=0 CENTRALSERVERHOSTNAME=servername CENTRALSERVERPORT=1234 CSUSER=userName /L*V C:\Windows\Temp\install.log"
I'm assuming you ran the .EXE directly with those args to verify their correctness?
If that's the case, try this:
Start-Process -Filepath "$workingDirectory\application.exe" -ArgumentList "/args", "/qn", "reboot=reallysuppress", "SILENT=yes", "INSTALLSTANDALONE=0", "CENTRALSERVERHOSTNAME=servername", "CENTRALSERVERPORT=1234", "CSUSER=userName", "/L*V", "C:\Windows\Temp\install.log"
Or this:
Start-Process -Filepath "$workingDirectory\application.exe" -ArgumentList #("/args", "/qn", "reboot=reallysuppress", "SILENT=yes", "INSTALLSTANDALONE=0", "CENTRALSERVERHOSTNAME=servername", "CENTRALSERVERPORT=1234", "CSUSER=userName", "/L*V", "C:\Windows\Temp\install.log")
Or this:
& "$workingDirectory\application.exe" /args /qn reboot=reallysuppress SILENT=yes INSTALLSTANDALONE=0 CENTRALSERVERHOSTNAME=servername CENTRALSERVERPORT=1234 CSUSER=userName /L*V C:\Windows\Temp\install.log
Alternatively, what happens when you remove the /qn arg?
I ran into a similar issue.
Changed this:
& "$workingDirectory\application.exe" /args /qn reboot=reallysuppress SILENT=yes INSTALLSTANDALONE=0 CENTRALSERVERHOSTNAME=servername CENTRALSERVERPORT=1234 CSUSER=userName /L*V C:\Windows\Temp\install.log
To this:
& "$workingDirectory\application.exe" /qn reboot=reallysuppress SILENT=yes INSTALLSTANDALONE=0 CENTRALSERVERHOSTNAME=servername CENTRALSERVERPORT=1234 CSUSER=userName /L*V C:\Windows\Temp\install.log
Source: https://social.technet.microsoft.com/wiki/contents/articles/7703.powershell-running-executables.aspx
$cs = New-PSSession -ComputerName MACHINE -Credential DOMAIN\admin
Copy-Item -Path C:\Scripts\smart -Destination C:\smart -ToSession $cs
msiexec /i "C:\Smart\SMART.msi" NB_PROD_KEY=NC-2ADA2-F9RKE-AKAIA-BBB ACTIVATE_LICENSE=1 INSTALL_INK="" LAT_CONTENT="" PRINT_CAPTURE="" INSTALL_DOCCAM_DRIVERS="" CUSTOMER_LOGGING=1 /qnT="" INSTALL_SPU=2 CUSTOMER_LOGGING=0 /qn
Hi,
I'm struggling to get the syntax that runs with the MSI working above - I've worked with switches inside script blocks which invoke commands beforfe successfully but, not with those parameters which are from the program vendors help file.
I also tried:
Start-Process "msiexec.exe" -Argumentlist "/i "C:\smartmsi\SMART.msi" `
NB_PROD_KEY=NC-2ADA2-F9RKE-AKAIA-BBB ACTIVATE_LICENSE=1 INSTALL_INK="" LAT_CONTENT="" PRINT_CAPTURE="" INSTALL_DOCCAM_DRIVERS="" CUSTOMER_LOGGING=1 /qn
Totally confused how to install using the vendors commands within POwerShell, how can i nest each argument if it's not a switch?
I also tried using Splatter:
$params = '/i', "C:\smartmsi\SMART.msi",
'NB_PROD_KEY=NC-2ADA2-CEAM7-F9RKE', 'ACTIVATE_LICENSE=1',
'/qn'
& msiexec.exe #params
$LastExitCode
No joy - this app will install remotely as a regular install.
Thanks in advance
UPDATE:
Now, i've also tried this:
invoke-command -Session $session -ScriptBlock {
Start-Process -FilePath C:\windows\system32\msiexec.exe `
-ArgumentList "/i `"C:\smart\SMARTSuite.msi`" `"NB_PROD_KEY=NC-2ADA2`" ACTIVATE_LICENSE=1 INSTALL_INK=`"`" LAT_CONTENT=`"`" PRINT_CAPTURE=`"`" INSTALL_DOCCAM_DRIVERS=`"`" CUSTOMER_LOGGING=1 /qn"
}
Still not working. Installer appears for a second then drops off.
You have to escape `" if you want them to be interpreted inside a string which already uses double quotes else you break the string chaining :
Start-Process -FilePath msiexec -ArgumentList "/i `"C:\smartmsi\SMART.msi`" NB_PROD_KEY=NC-2ADA2-F9RKE-AKAIA-BBB ACTIVATE_LICENSE=1 INSTALL_INK=`"`" LAT_CONTENT=`"`" PRINT_CAPTURE=`"`" INSTALL_DOCCAM_DRIVERS=`"`" CUSTOMER_LOGGING=1 /qn"
You don't have to escape double quotes if the string is surrounded by simple quotes