Skip to content

Powershell 7 Preview 5 | Select-String -Pattern crashes when executed in ForEach-Object -Parallel #11052

Closed

Description

Steps to reproduce

0..0 | ForEach-Object -Parallel {
    $regExpRule = "this (.+) test"
    "it looks like this is a test!" | Select-String -Pattern $regExpRule
}

Expected behavior

Should print out

it looks like this is a test!

Actual behavior

The executed code crashes with the following error

Select-String:
Line |
   3 | "it looks like this is a test!" | Select-String -Pattern $regExpRule
     |                                   ^ Object reference not set to an instance of an object.

Environment data


Name                           Value
----                           -----
PSVersion                      7.0.0-preview.5
PSEdition                      Core
GitCommitId                    7.0.0-preview.5
OS                             Microsoft Windows 10.0.18363
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Activity

  1. added
    Issue-Question
    on Nov 12, 2019
  2. iSazonov commented on Nov 15, 2019

    @iSazonov
    Collaborator

    Paul Higinbotham (@PaulHigin) Could you please look the issue?

    I tried follow with strange behavior:

    0..0 | ForEach-Object -Parallel {
    	$Host.UI.SupportsVirtualTerminal
    }
    function qqq {
    [CmdletBinding()]
    param()
    	$Host.UI.SupportsVirtualTerminal
    }
    
    0..0 | ForEach-Object -Parallel {
        qqq
    }
    0..0 | ForEach-Object -Parallel {
    function qqq {
    [CmdletBinding()]
    param()
    	$Host.UI.SupportsVirtualTerminal
    }
    	qqq
    }
  3. added
    WG-Cmdlets
    and removed on Jul 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-QuestionResolution-FixedWG-Cmdlets

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions