PSADT 4 calling system variables in -ArgumentList

Package calls a command utility to import an XML config file after install. My script copies the file to the local path and runs the CLI.

If I were to run the import from a prompt, it would be

"C:\Program Files\Fortinet\FortiClient\FCConfig.exe" -m vpn -f "C:\Program Files\Fortinet\FortiClient\IntegraVPN.conf" -o import -p <password>

To get PSADT to work without error. I learned I did not need to include the path for the .CONF file to get it to run successfully

Start-ADTProcess -FilePath "$envProgramFiles\Fortinet\FortiClient\FCConfig.exe" -ArgumentList "-m vpn -f IntegraVPN.conf -o import -p <password>"

However, after import into Intune and run the package. it does not seem to resolve where the CONF file is and fails the entire post install section of my script. Intune error shows

The filename, directory name, or volume label syntax is incorrect (0x8007007B)

Trace Log shows

[Post-Install] :: Executing [C:\Program Files\Fortinet\FortiClient\FCConfig.exe -m vpn -f IntegraVPN.conf -o import -p “password”]…
[Post-Install] :: Execution failed with exit code [-1073741701].

For Intune to work, I need to put in the path for the config file in my -ArguementList, but I am missing something properly declaring the path.

I have tried

 AppImport = '"$envProgramFiles\Fortinet\FortiClient\FIntegraVPN.conf"'
Start-ADTProcess -FilePath "$envProgramFiles\Fortinet\FortiClient\FCConfig.exe" -ArgumentList "-m vpn -f $($adtSession.AppImport) -o import -p <password>"

(I had set my variable with and without double quotes) The PSADT script fails because it’s not recognizing the variable $envProgramFiles.

From the logs;

[Post-Install] :: Executing [C:\Program Files\Fortinet\FortiClient\FCConfig.exe -m vpn -f $envProgramFiles\Fortinet\FortiClient\FIntegraVPN.conf -o import -p “password”]…
[Post-Install] :: Execution failed with exit code [-1073741515].

If I try to just put the path into the -ArguementList with escape quotes, everything after is misrepresented.

`Start-ADTProcess -FilePath "$envProgramFiles\Fortinet\FortiClient\FCConfig.exe" -ArgumentList "-m vpn -f '"$envProgramFiles\Fortinet\FortiClient\FCConfig.exe'" -o import -p <password>"`

If I encapsulate the argument in single quotes, the string looks right, but the outcome is the same.

Start-ADTProcess -FilePath "$envProgramFiles\Fortinet\FortiClient\FCConfig.exe" -ArgumentList '-m vpn -f "$envProgramFiles\Fortinet\FortiClient\FCConfig.exe" -o import -p <password>'

What am I missing?
TIA

It’s as if Start-ADTProcess is eating/ignoring the double quotes.

One thing I did notice is this wont work:

 AppImport = '"$envProgramFiles\Fortinet\FortiClient\FIntegraVPN.conf"'
Start-ADTProcess -FilePath "$envProgramFiles\Fortinet\FortiClient\FCConfig.exe" -ArgumentList "-m vpn -f $($adtSession.AppImport) -o import -p <password>"

because the outer single quotes tell PowerShell not to expand variables.

If you want to include double quotes inside double quotes, try this:

 AppImport = "`"$envProgramFiles\Fortinet\FortiClient\FIntegraVPN.conf`""
Start-ADTProcess -FilePath "`"$envProgramFiles\Fortinet\FortiClient\FCConfig.exe`"" -ArgumentList "-m vpn -f $AppImport -o import -p <password>"

The back-ticks ( ` ) tell PowerShell to treat the double quotes literally. IOW: include the double quotes with the rest.

This might be a bug.

2 Likes

Short answer, I resolved the line doing the following,

Start-ADTProcess -FilePath "$envProgramFiles\Fortinet\FortiClient\FCConfig.exe" -ArgumentList "-m vpn -f `"$envProgramFiles\Fortinet\FortiClient\IntegraVPN.conf`" -o import -p <password>"

When I attempted your suggestion. The $AppImport was completely omitted when the line executed and would not populate the string.

Thanks for the help, again!

1 Like

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