您好,Powershell专家
下面是我的 test.ps1 脚本
function HelloNumberOne {Write-Host "Hello Number 1"}
function HelloNumberTwo {Write-Host "Hello Number 2"}
function HelloNumberThree {Write-Host "Hello Number 3"}
function HelloNumberFour {Write-Host "Hello Number 4"}
function HelloNumberFive {Write-Host "Hello Number 5"}
function HelloNumberSix {Write-Host "Hello Number 6"}
当我尝试按照here
并行运行它们时workflow RunParallel{
parallel {
{HelloNumberOne}
{HelloNumberTwo}
{HelloNumberThree}
{HelloNumberFour}
{HelloNumberFive}
{HelloNumberSix}
}
}
RunParallel
什么也没执行。是否有人能够并行执行位于同一 .ps1 文件中的功能?
答案 0 :(得分:2)
正如希西马(Hsimah)所指出的,您需要去除花括号
工作流程并行运行
parallel {
HelloNumberOne
HelloNumberTwo
HelloNumberThree
HelloNumberFour
HelloNumberFive
HelloNumberSix
}
}
这些工作流程不会向主机输出任何数据,如果需要捕获如下所示的输出,则需要使用变量
workflow Run-Parallel{
parallel {
$a= HelloNumberOne
HelloNumberTwo
}
}
$a