Please note:
$YourString = '"/X' $id1 '/QN KLPASSWD=randompass'""
See @dennis's answer for better understanding.
If randompass
contains spaces, you must enclose it in quotes, see @maximilian-burszley's comment.
The simplest way to use the ArgumentList
parameter is to treat it as an array
and not as a string
. This makes it easier to debug any exceptions.
$ParameterArgumentList =
'/X',
$id1,
'/QN',
'KLPASSWD=randompass'
The code excerpt would be:
(Start-Process msiexec.exe -ArgumentList $ParameterArgumentList -Wait).ExitCode
To display your array:
Write-Output -InputObject $ParameterArgumentList