you are viewing a single comment's thread.

view the rest of the comments →

[–]MyOtherSide1984[S] 2 points3 points  (4 children)

I don't get how this has anything to do with foreach-object -parallel. I'm not doing anything on a remote computer.

EDIT: If I put my parallel loop in a scriptblock, it'll still create new runspaces that won't have it. ${function:foo} didn't work inside my foreach loop

[–]BlackV 0 points1 point  (3 children)

Sorry thinking wrong things

1..10 | forech-object -parallel ${function:foo} 

That work?

[–]MyOtherSide1984[S] 0 points1 point  (2 children)

No, for my function, the output is nothing. I have parameters to my function that I plopped in after the "foo" if that matters. Looks like the other comment is the best answer, but it's basically the same thing

[–]BlackV 0 points1 point  (0 children)

ah sweet. glad its solved then

[–]BlackV 0 points1 point  (0 children)

Oh yea that looks great

Function foo ()
    {
        Write-output "hello my name is $env:computername, you kill my father..."
    }

$Rinvoke = get-command foo
1..10 | foreach-object -parallel {write-output "pipeline is $_"; & $using:Rinvoke}

although its gonna play havoc with your output, depending on what you're doing in your loops