I was wondering if someone with more expertise could help me with a little problem I'm having with using Variables in -ArgumentList when using Start-Process.
If I run the Exe without using Start-Process
.\DeploymentServer.UI.CommandLine.exe register --estNumber $Number --postcode $PostCode --password $Password
everything works fine, the command runs and the software is registered.
If I try
Start-Process .\DeploymentServer.UI.CommandLine.exe -ArgumentList "register --estNumber $Number --postcode $PostCode --password $Password" -Wait -NoNewWindow
or
$Arguments = "register --estNumber $Number --postcode $PostCode --password $Password"
Start-Process .\DeploymentServer.UI.CommandLine.exe -ArgumentList $Arguments -NoNewWindow -Wait
the command runs but is unable to register, stating that it can not match the details provided. So I'm assuming the issue lies either in the passing of the arguments to Start-Process, or -ArgumentList interpreting the variables in the string. Am I missing something really simple here? Possibly to do with the $ in the -ArgumentList?
Start-Processnever add quotes for you, while PowerShell normally try to be smart and add quotes, when arguments contains spaces:$Text='With Space';start cmd "/c echo $Text" -NoNewWindow -Wait;cmd /c echo $Text.