Passing multiple parameters to Execute-Process

hi

I am needing help trying to install an application with multiple paramaters. How do we need to send to exe? Confused with quotes below is the code to be sent

Qualysagent.exe Customerid=xxxxx Activationid=xxxxxxxx WebserviceUri=https:\xxxxx

Tried one:-
Doesn’t work, Please help

Execute-Process -Path 'Qualysagent.exe ' -Parameters "`"Customerid=xxxxx Activationid=xxxxxxxx WebserviceUri=https:\\xxxxx`"`""

First thing, that trailing space for the EXE might cause problems

Second, I don’t think you need to escape the double quotes for your parameters. None seem to have spaces.

If you are curious how escaping quotes work in PowerShell, look at Silent Install asks for input (InstallShield Quotes issue)

Thank you but still get error below error, Please help with quotes

Below works in cmd but not in PS script->
QualysCloudAgent.exe CustomerId={xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx} ActivationId={xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx} WebServiceUri=https://xxxxxxx.xxx.xxxx.qualys.com/CloudAgent/

Code tried →
Execute-Process -Path "$dirFiles\QualysCloudAgent.exe" -Parameters "`"CustomerId={xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx}`" `"ActivationId={xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx}`" WebServiceUri=https://xxxxxxx.xxx.xxxx.qualys.com/CloudAgent/`""

I think (as @That-Annoying-Guy inferred) your use of escaping the double quotes is not necessary (on this occasion)
Have you simply tried this (N.B. I also changed the Qualysagent.exe from single quotes to double quotes):

Execute-Process -Path "$dirFiles\Qualysagent.exe" -Parameters "Customerid={xxxxx} Activationid={xxxxxxxx} WebserviceUri=https:\\xxxxx"

or maybe (Note: Escaped double quotes around WebServiceUri / Url):

Execute-Process -Path "$dirFiles\Qualysagent.exe" -Parameters "Customerid={xxxxx} Activationid={xxxxxxxx} WebserviceUri=`"https:\\xxxxx`""

It’s the {curly brackets} . They are reserved characters in PowerShell. Either remove them or escape them like this:

Execute-Process -Path "$dirFiles\QualysCloudAgent.exe" -Parameters "`"CustomerId=`{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx`}`" `"ActivationId=`{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx`}`" WebServiceUri=https://xxxxxxx.xxx.xxxx.qualys.com/CloudAgent/`""

FYI: I added triple back-ticks to your post where you posted code. it makes it possible to display back tick. (Discourse uses Markdown for formatting)

2 Likes

This worked thanks but couldnt create log file.

Execute-Process -Path “$dirFiles\QualysCloudAgent.exe” -Parameters “CustomerId={xxxxx} ActivationId={xxxxx} WebServiceUri=https:/xxxxxxxx.xxx.xxxx.qualys.com/CloudAgent/”

Below is the log file failed code, maybe exe doesnt support log switch.

Execute-Process -Path "$dirFiles\QualysCloudAgent.exe" -Parameters "CustomerId={xxxxx}  ActivationId={xxxxx} WebServiceUri=https:/xxxxxxxx.xxx.xxxx.qualys.com/CloudAgent/" /LOG=`"$configToolkitLogDir\$appPackageName.log`""

Thanks for the help!

you left the terminating double quote: CloudAgent/"

Try this:

Execute-Process -Path "$dirFiles\QualysCloudAgent.exe" -Parameters "CustomerId={xxxxx}  ActivationId={xxxxx} WebServiceUri=https:/xxxxxxxx.xxx.xxxx.qualys.com/CloudAgent/ /LOG=`"$configToolkitLogDir\$appPackageName.log`""

I’m surprised that it’s /LOG and not -LOG like the other paramaters.

3 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.