我有一个test.bat批处理文件来启动PowerShell脚本:使用蝙蝠开始PowerShell脚本
@pushd "C:\myscripts"
powershell .\test.ps1 arg1 "arg2 with space" arg3
@popd
脚本test.ps1(位于C:\ myscripts)是一个非常简单的,如:
# just print out the arguments
Write-Output ("args count: {0}" -f $args.length)
$args
然后我试着启动test.bat。我应该得到三个参数传递给PS1,但我得到了以下结果:
ARGS数:5 ARG1 ARG2 与 空间 ARG3
我预计在脚本什么,ARGS [0]应该ARG1 args [1]应该是“arg2 with space”,args3 [2]是arg3。我不明白为什么脚本实际上有5个参数。
如何将cmd或batch中的参数传递给PowerShell?就像这样:
args count: 3
arg1
arg2 with space
arg3
他们没有。但是它们对于'cmd'确实意味着不同的东西。 – Joey 2009-11-26 17:16:43