Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

chaining script cmdlets which use -pipelinevariable do not work as expected #19618

Copy link
Copy link
@JamesWTruher

Description

@JamesWTruher
Issue body actions

Prerequisites

Steps to reproduce

create 2 functions:

PS> function cmdletB {[CmdletBinding()]param()BEGIN{"b2"}PROCESS{"! p2 !"}END{"e2"}}                                              
PS> function cmdletA {[CmdletBinding()]param()BEGIN{"b1"}PROCESS{"! p1 !";cmdletB}END{"e1"}}               

this will operate as expected:

PS> cmdletA -pv a| % {"> $a <"}
> b1 <
> ! p1 ! <
> b2 <
> ! p2 ! <
> e2 <
> e1 <

however, if you add -pv a to the invocation of cmdletB, you can see the issue.

PS> function cmdletA {[CmdletBinding()]param()BEGIN{"b1"}PROCESS{"! p1 !";cmdletB -pv a}END{"e1"}}
PS> cmdletA -pv a| % {"> $a <"}                                                                   
> b1 <
> ! p1 ! <
> ! p1 ! <
> ! p1 ! <
> ! p1 ! <
> e1 <

it seems to lose all output from cmdletB.
It doesn't seem to matter if you choose a different pipeline variable for cmdletB

PS> function cmdletA {[CmdletBinding()]param()BEGIN{"b1"}PROCESS{"! p1 !";cmdletB -pv b}END{"e1"}}
PS> cmdletA -pv a| % {"> $a $b <"}                                                                
> b1  <
> ! p1 !  <
> ! p1 !  <
> ! p1 !  <
> ! p1 !  <
> e1  <

possibly related to:
#16199
#12766

Expected behavior

PS> cmdletA -pv a| % {"> $a <"}
> b1 <
> ! p1 ! <
> b2 <
> ! p2 ! <
> e2 <
> e1 <

Actual behavior

PS> cmdletA -pv a| % {"> $a <"}                                                                   
> b1 <
> ! p1 ! <
> ! p1 ! <
> ! p1 ! <
> ! p1 ! <
> e1 <

Error details

no error

Environment data

PS> $psversiontable     

Name                           Value
----                           -----
PSVersion                      7.4.0-preview.3
PSEdition                      Core
GitCommitId                    7.4.0-preview.3-29-g07e041fe10d4c753dfccfa46008bdedebdfd3027
OS                             Darwin 22.4.0 Darwin Kernel Version 22.4.0: Mon Mar  6 21:00:17 PST 2023; root:xnu-8796.101.5~3/RELEASE_X86_64
Platform                       Unix
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Visuals

No response

Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs-TriageThe issue is new and needs to be triaged by a work group.The issue is new and needs to be triaged by a work group.Resolution-No ActivityIssue has had no activity for 6 months or moreIssue has had no activity for 6 months or more

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.