Command Prompt executes this correctly but Powershell doesn't?

Question

Having some weirdness where Powershell is not executing this command correctly. It can't understand the INSTALLFOLDER or TARGETDIR and just throws up the Windows Installer help box.

Whereas command prompt processes this just fine??? It's very weird. PS version is 5.1.18362 I believe.

the command is

msiexec.exe /i "C:\Users\sadas\aasasdd\sda\asdasd\19526-Debug-x64.msi" INSTALLFOLDER="C:\Installation Test" /qn

My msi is a Wix installer msi and has the property INSTALLFOLDER

Solution

This is not how you run this command in PowerShell. There are several ways to run external command in PowerShell and it a well-documented use case. Links to follow

• Using PowerShell and external commands and their parameters or switches. Running external commands, always require special consideration.

• PowerShell: Running Executables

• Solve Problems with External Command Lines in PowerShell

• Top 5 tips for running external commands in Powershell

• Using Windows PowerShell to run old command-line tools (and their weirdest parameters)

• Execution of external commands in PowerShell done right https://mnaoumov.wordpress.com/2015/01/11/execution-of-external-commands-in-powershell-done-right

https://mnaoumov.wordpress.com/2015/03/31/execution-of-external-commands-native-applications-in-powershell-done-right-part-2

https://mnaoumov.wordpress.com/2015/04/05/execution-of-external-commands-native-applications-in-powershell-done-right-part-3

http://edgylogic.com/blog/powershell-and-external-commands-done-right

• Quoating specifics

https://trevorsullivan.net/2016/07/20/powershell-quoting

PowerShell has a list of characters that mean specific things, vs what cmd.exe implementation means, and if you need those, they must be properly terminated. See the below

About Special Characters

PowerShell - Special Characters And Tokens

So, to make your command work in the PowerShell consolehost, ISE, VSCode, do something like this...

# Using teh Call operator
& 'msiexec.exe /i "C:\Users\sadas\aasasdd\sda\asdasd\19526-Debug-x64.msi" INSTALLFOLDER="C:\Installation Test" /qn'

or

... this...

# Using Start-Process
$ConsoelCommand = 'msiexec.exe /i "C:\Users\sadas\aasasdd\sda\asdasd\19526-Debug-x64.msi" INSTALLFOLDER="C:\Installation Test" /qn'
Start-Process powershell -ArgumentList "-NoExit","-Command  &{ $ConsoleCommand }" -Wait