我如何在PowerShell中使用大型多行脚本块开始处理?

时间:2016-08-07 04:32:06

标签: powershell scripting

我想用脚本块启动进程powershell。  喜欢这段代码。

start-process powershell.exe -ArgumentList "-noexit","-command {
set-Set-ExecutionPolicy bypass -force
get-help get-process
get-command -commandtype cmdlet
...
}"

2 个答案:

答案 0 :(得分:1)

Command的参数应该是ArgumentList中未合并到-command的另一个元素。

Start-Process powershell.exe -ArgumentList "-noexit", "-command", "Get-Process"

这适用于您执行的事情是简单命令还是更长命令(非常长的字符串)。

答案 1 :(得分:0)

您可以使用此方法:

Start-Process powershell.exe -ArgumentList "-noexit", "-command", "help
dir
get-command
" 
相关问题