2

Hello powershell experts,

Below is my test.ps1 script

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"}

When I try to run them in parallel as described here

workflow RunParallel{ 
parallel {

   {HelloNumberOne}   
   {HelloNumberTwo}
   {HelloNumberThree}
   {HelloNumberFour}
   {HelloNumberFive}
   {HelloNumberSix}
  }
}

RunParallel

Nothing get's executed. Has anyone been able to execute functions, that are located in same .ps1 file, in parallel?

1
  • 1
    You need to remove the wrapped braces around the function calls in your parallel script block. Commented May 7, 2019 at 21:52

1 Answer 1

2

As Hsimah, pointed out , you need to remove curly braces

workflow Run-Parallel{

parallel {

    HelloNumberOne   
    HelloNumberTwo
   HelloNumberThree
   HelloNumberFour
   HelloNumberFive
   HelloNumberSix
  }
}

These workflows , will not output any data to host, you need to use variables, if you need to capture output like below

workflow Run-Parallel{ 
parallel {

   $a=  HelloNumberOne   
    HelloNumberTwo
  }
}

$a 
Sign up to request clarification or add additional context in comments.

2 Comments

Thanks @TheGameiswar for your answer. It did work. Interesting thing is: even not declaring a variable, the output is still printed at the host.
wow,strange..with the given example, i am not able to get any output

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.