How do I pass in a string with spaces into PowerShell?

前端 未结 4 1644
庸人自扰
庸人自扰 2020-12-18 21:38

Given:

# test1.ps1
param(
    $x = \"\",
    $y = \"\"
)

&echo $x $y

Used like so:

powershell test.ps1
4条回答
  •  北荒
    北荒 (楼主)
    2020-12-18 22:06

    Randomly found this today; you can use a backtick ` to escape spaces:

    PS & C:\Program` Files\....

    Just in case anyone stumbles onto this again

提交回复
热议问题