2

I want to run a powershell process with a command list. I'm having an issue with using a string in an argumentlist with a command list.

This is what I try to run:

Start-Process Powershell -ArgumentList '-command "$var = "test""'

But it results in:

The term 'test' is not recognized as the name of a cmdlet, function, script file, or operable program.

I tried the same with:

Start-Process Powershell -ArgumentList '-command "$var = `"test`""'

But also with a negative result.

Any ideas how to solve this issue?

mklement0
  • 382,024
  • 64
  • 607
  • 775
miket2000
  • 23
  • 3

1 Answers1

1

Perhaps surprisingly, PowerShell's CLI (powershell.exe) requires embedded " chars. to be escaped as \", not as `":

Start-Process Powershell -ArgumentList '-command "$var = \"test\""'
mklement0
  • 382,024
  • 64
  • 607
  • 775