使用批处理脚本中的参数运行PowerShell脚本 [英] running a PowerShell script with parameters from a batch script
本文介绍了使用批处理脚本中的参数运行PowerShell脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在处理批处理脚本以读取一些参数并启动PowerShell脚本,该脚本需要输入参数.
I am working on a batch script to read in some parameters and start a PowerShell script, which needs the typed in parameters.
到目前为止我所做的:
Set /p arg1 = Type in a name for the data:
Set /p arg2 = Type in the directory of the project:
Set /p arg3 = Type in the programming language :
Set /p arg4 = Type in a version for the metric data:
SET ThisScriptsDirectory=%~dp0
SET PowerShellScriptPath=%ThisScriptsDirectory%Metrics.ps1
PowerShell -NoProfile -ExecutionPolicy Bypass -Command "& '%PowerShellScriptPath%' 'arg1' 'arg2' 'arg3' 'arg4'";
不幸的是,PowerShell脚本不接受参数.
Unfortunally the PowerShell script doesn't accept the parameters.
推荐答案
PowerShell -NoProfile -ExecutionPolicy Bypass -file "%PowerShellScriptPath%" %arg1% %arg2% ....
这篇关于使用批处理脚本中的参数运行PowerShell脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文