Install EXE Commandline Arguments

I'm new to using PSADT. I have an EXE installer, that uses a Config.json file and some other switches to install. What I'm having a big problem with is pointing to the config.json file and it passing the path to the file, to the installer. This is my CMD file, that works:

"%~dp0ITMSaaSBundle-4.3.3.530-x64.exe" /install /quiet /norestart contentdetection=1 TargetDir="C:\Program Files\IT Client Utility\Client Utility" PreConfigPath="%~dp0nmdp-general_agent_install_config.json" /log c:\nmdpbld\pkg\logs\ITMSaaSBundle_SetupLog.log

Everything I've tried for the PreConfigPatch= has failed to pass on to the installer.

As a workaround, I did a pre-install command, copy the json file to a temp folder locally, run the install, the a post-install command to delete the json file.

Is there a way to do this without copying the file locally, and calling it from there?

Hello @khanlin - Welcome

Your batch file script uses cmd specific code that does not directly translate well into PowerShell

You currently have this:

"%~dp0ITMSaaSBundle-4.3.3.530-x64.exe" /install /quiet /norestart contentdetection=1 TargetDir="C:\Program Files\IT Client Utility\Client Utility" PreConfigPath="%~dp0nmdp-general_agent_install_config.json" /log c:\nmdpbld\pkg\logs\ITMSaaSBundle_SetupLog.log

FYI: The %~dp0 prefixes means that the paths to the .exe and .json in the script is completely location agnostic when it is run.
For this to be useful to translate into PowerShell you first will need to remove the %~dp0 prefixes from any commands, this therefore becomes:

"ITMSaaSBundle-4.3.3.530-x64.exe" /install /quiet /norestart contentdetection=1 TargetDir="C:\Program Files\IT Client Utility\Client Utility" PreConfigPath="nmdp-general_agent_install_config.json" /log c:\nmdpbld\pkg\logs\ITMSaaSBundle_SetupLog.log

You now have the basic script that can be 'directly' translated into something usable in PowerShell / PSADT

Before I go any further you will need to make sure both your installer (ITMSaaSBundle-4.3.3.530-x64.exe) and your .JSON file (nmdp-general_agent_install_config.json) are in the .\Files folder in your PSADT package.
N.B. This folder path is stored in the $($adtSession.DirFiles) variable.

Assuming your files are in place, Your PSADT install command line should be constructed something like this (Be aware this is untested, so may need some further work):

Start-ADTProcess -FilePath "$($adtSession.DirFiles)\ITMSaaSBundle-4.3.3.530-x64.exe" -ArgumentList "/install /quiet /norestart contentdetection=1 TargetDir=`"C:\Program Files\IT Client Utility\Client Utility`" PreConfigPath=`"$($adtSession.DirFiles)\nmdp-general_agent_install_config.json`" /log `"c:\nmdpbld\pkg\logs\ITMSaaSBundle_SetupLog.log`"" -WindowStyle 'Hidden'

Note: I have wrapped the whole of your list of Arguments (in the -ArgumentsList switch) within a pair of double quotes so the variable $($adtSession.DirFiles) can be successfully expanded, but this requires any additional double quotes used within the -ArgumentsList to be escaped so they are read correctly. You (generally) use the ` character to escape something in PowerShell.
But, if you wrapped any content in single quotes PowerShell reads this as text so the variables would not be expanded, resulting in the .exe or .json files unlikely to be found.

Let us know how you get on

Thank you very much for the help on this.