Skip to content

For ForEach-Object -Parallel, nested loops improvment #11817

@PrzemyslawKlys

Description

@PrzemyslawKlys

While you're at improving ForEach-Object -Parallel please address this:

Doesn't work

$OhMy = 'Test'
(1..100) | ForEach-Object -Parallel {
    $Test = $Using:OhMy
    (1..50) | ForEach-Object -Parallel {
        $Test5 = $Using:Test
    }
}

image

Works:

$OhMy = 'Test'
$Test = $null
(1..100) | ForEach-Object -Parallel {
    $Test = $Using:OhMy
    (1..50) | ForEach-Object -Parallel {
        $Test5 = $Using:Test
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Documentation Needed in this repoDocumentation is needed in this repoIssue-Questionideally support can be provided via other mechanisms, but sometimes folks do open an issue to get aResolution-No ActivityIssue has had no activity for 6 months or moreWG-Cmdlets-Corecmdlets in the Microsoft.PowerShell.Core module

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions