在powershell脚本中,我需要启动进程powershell并告诉它像这样运行脚本foo.ps1:
start-process powershell C:\foodir\foo.ps1
但是当我需要使用参数运行脚本foo时,我遇到了问题。我试过这样的代码:
start-process powershell (C:\foodir\foo.ps1 -paramforfoo test)
但这只是在脚本到达此行时冻结并且不会抛出任何错误。我认为它试图将参数测试传递给powershell进程而不是脚本foo。如何使用参数运行此脚本?
答案 0 :(得分:0)
尝试使用引号来收集命令。 E.g。
Start-Process powershell ".\Untitled3.ps1 -testparam 'hello world'"