0

Assume you want to replace the call some_program.exe --foo --bar in your PowerShell script with some_program.exe $env:ARGS, where $env:ARGS has the value --foo --bar. How do you do it?

Right now, when calling some_program.exe $env:ARGS, the argument parser of some_program will think that it has been called with one argument that has the value --foo --bar, but I want it to think that it has been called with two arguments, one being --foo, one being --bar.

MShekow
  • 1,487
  • 2
  • 14
  • 26
  • 2
    The naive answer is `some_program.exe (-split $env:ARGS)`, but that doesn't work if _quoted_ arguments are present inside the `$env:ARGS` value. See the linked duplicate for more information, including a solution to the latter problem. – mklement0 Mar 01 '22 at 13:34

0 Answers0