Skip to content

Pwsh 7: Could not resolve Foreach-Object 's -Parallel argument using ConvertTo-SplatExpression  #69

Description

@SeeminglyScience

Moved from PowerShell/PowerShellEditorServices#1610 from @ninmonkey (thanks for the report!)


Issue:

Splat is outputting this

$forEachObjectSplat = @{
    Parallel = -Parallel
}
Get-Process | ForEach-Object @forEachObjectSplat {

image

Expected Behaviour

-parallel should splat as a bool

To reproduce

Use ConvertTo-SplatExpression on the For-EachObject

$threadSafeDictionary = [System.Collections.Concurrent.ConcurrentDictionary[string, object]]::new()
Measure-Command -Expression { & {

        Get-Process | ForEach-Object -Parallel -ThrottleLimit 3 -UseNewRunspace {
            $dict = $using:threadSafeDictionary
            $dict.TryAdd($_.ProcessName, $_)
        }
    }
}

$threadSafeDictionary.Values | Format-Table -AutoSize

Behavior

Creating new windows, keeps reproducing the error
parallel splat ┐ pwsh 7 1 ┐ part1- 2021-10-01

parallel splat ┐ pwsh 7 1 ┐ part2- 2021-10-01

Environment

test 1

Addon Version
ms-vscode.powershell-preview 2021.10.3
TylerLeonhardt.vscode-inline-values-powershell 0.0.5
TylerLeonhardt.vscode-pester-test-adapter 0.0.23
code --version
code version: 1.59.1, 3866c3553be8b268c8a7f8c0482c0c0177aa8bfa, x64

test 2

Addon Version
justin-grote.powershell-extension-pack 0.0.5
ms-vscode-remote.remote-ssh-edit 0.65.8
ms-vscode.powershell-preview 2021.9.2
nickdemayo.vscode-json-editor 0.3.0
PowerQuery.vscode-powerquery 0.1.23
rust-lang.rust 0.7.8
TylerLeonhardt.vscode-inline-values-powershell 0.0.5
PSVersion GitCommitId OS                           PSEdition
--------- ----------- --                           ---------
7.1.4     7.1.4       Microsoft Windows 10.0.19043 Core

code-insiders --version
1.62.0-insider, 284e0db6c4cac1e557a43cd6691babdaafc2e1a9, x64

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions