Title: -PipelineVariable is only assigned output from the first execution of the first function block · Issue #10932 · PowerShell/PowerShell · GitHub
Open Graph Title: -PipelineVariable is only assigned output from the first execution of the first function block · Issue #10932 · PowerShell/PowerShell
X Title: -PipelineVariable is only assigned output from the first execution of the first function block · Issue #10932 · PowerShell/PowerShell
Description: Steps to reproduce function foo { [cmdletbinding()] Param([parameter(ValueFromPipeline)]$a) Begin {1} Process {2} End {3} } Write-Host -ForegroundColor Green 'Expected:' 1..3|foo|%{$_} -pv x -ov y |select {$x},{$_},{$y}|out-host Write-Ho...
Open Graph Description: Steps to reproduce function foo { [cmdletbinding()] Param([parameter(ValueFromPipeline)]$a) Begin {1} Process {2} End {3} } Write-Host -ForegroundColor Green 'Expected:' 1..3|foo|%{$_} -pv x -ov y ...
X Description: Steps to reproduce function foo { [cmdletbinding()] Param([parameter(ValueFromPipeline)]$a) Begin {1} Process {2} End {3} } Write-Host -ForegroundColor Green 'Expected:' 1..3|foo|%{$_} -pv ...
Opengraph URL: https://github.com/PowerShell/PowerShell/issues/10932
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"-PipelineVariable is only assigned output from the first execution of the first function block","articleBody":"# Steps to reproduce\r\n\r\n```powershell\r\nfunction foo {\r\n [cmdletbinding()]\r\n Param([parameter(ValueFromPipeline)]$a)\r\n Begin {1}\r\n Process {2}\r\n End {3}\r\n}\r\nWrite-Host -ForegroundColor Green 'Expected:'\r\n1..3|foo|%{$_} -pv x -ov y |select {$x},{$_},{$y}|out-host\r\n\r\nWrite-Host -ForegroundColor Green 'Actual:'\r\n1..3|foo -pv x -ov y |select {$x},{$_},{$y}|out-host\r\n```\r\n\r\nOutput:\r\n\r\n```\r\nExpected:\r\n\r\n$x $_ $y\r\n-- -- --\r\n 1 1 1\r\n 2 2 {1, 2}\r\n 2 2 {1, 2, 2}\r\n 2 2 {1, 2, 2, 2}\r\n 3 3 {1, 2, 2, 2…}\r\n\r\nActual:\r\n\r\n$x $_ $y\r\n-- -- --\r\n 1 1 1\r\n 2 {1, 2}\r\n 2 {1, 2, 2}\r\n 2 {1, 2, 2, 2}\r\n 3 {1, 2, 2, 2…}\r\n```\r\n\r\n# Expected behavior\r\n\r\nAll output produced in any block (Begin, Process, or End) should be assigned to the PipelineVariable as it enters the pipeline. -OutVariable appears to behave correctly, i.e. it captures output that -PipelineVariable does not.\r\n\r\n# Actual behavior\r\n\r\nOnly output produced by the first block to exectute, and only on the first execution of that block is assigned to the PipelineVariable.\r\n\r\nExamples: \r\n\r\n* if a Begin block exists, the output from the Begin block will be assigned, but the output from the Process and End blocks will not.\r\n* if a Begin block does not exists, the output from the first execution of the Process block will be assigned, but the output from subsequent executions of the Process block will not, and the output of the End block will not.\r\n\r\nIn the wild, on 5.1:\r\n\r\nhttps://stackoverflow.com/questions/45782372/powershell-advanced-function-output-pipelinevariable-doesnt-work\r\n\r\nhttps://www.reddit.com/r/PowerShell/comments/doboko/support_for_pipelinevariable_in_advanced_function/\r\n\r\n\r\n# Environment data\r\n\r\n\u003c!-- provide the output of $PSVersionTable --\u003e\r\n\r\n```none\r\nName Value\r\n---- -----\r\nPSVersion 7.0.0-preview.5\r\nPSEdition Core\r\nGitCommitId 7.0.0-preview.5\r\nOS Microsoft Windows 10.0.18362\r\nPlatform Win32NT\r\nPSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}\r\nPSRemotingProtocolVersion 2.3\r\nSerializationVersion 1.1.0.1\r\nWSManStackVersion 3.0\r\n```\r\n","author":{"url":"https://github.com/bstrautin","@type":"Person","name":"bstrautin"},"datePublished":"2019-10-29T14:47:06.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":11},"url":"https://github.com/10932/PowerShell/issues/10932"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:eed713e0-d0cd-d83b-9408-e605e6781586 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B17A:E7D9B:21D74C9:2D004AE:6A51F852 |
| html-safe-nonce | 5b57290e9b22f5cb957dff54028d964c7a698a70faad55fc7924b05b852c153e |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCMTdBOkU3RDlCOjIxRDc0Qzk6MkQwMDRBRTo2QTUxRjg1MiIsInZpc2l0b3JfaWQiOiI3NDE1ODczODYwMzE1MzYyMTAiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 5c7cd663be475b1113c0cd5b1fa2a260ccb53f7552ae59f2c6d93d0d9687f86c |
| hovercard-subject-tag | issue:513974135 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/PowerShell/PowerShell/10932/issue_layout |
| twitter:image | https://opengraph.githubassets.com/7f61006a5193cd9c6114363d1419da733647f34ab7504b4b546e3cf7b140f1f1/PowerShell/PowerShell/issues/10932 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/7f61006a5193cd9c6114363d1419da733647f34ab7504b4b546e3cf7b140f1f1/PowerShell/PowerShell/issues/10932 |
| og:image:alt | Steps to reproduce function foo { [cmdletbinding()] Param([parameter(ValueFromPipeline)]$a) Begin {1} Process {2} End {3} } Write-Host -ForegroundColor Green 'Expected:' 1..3|foo|%{$_} -pv x -ov y ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | bstrautin |
| hostname | github.com |
| expected-hostname | github.com |
| None | b9a586c06a05a7a86fc7e3f4dbd03e42f6869085879aa184aa6369456dbd50fb |
| turbo-cache-control | no-preview |
| go-import | github.com/PowerShell/PowerShell git https://github.com/PowerShell/PowerShell.git |
| octolytics-dimension-user_id | 11524380 |
| octolytics-dimension-user_login | PowerShell |
| octolytics-dimension-repository_id | 49609581 |
| octolytics-dimension-repository_nwo | PowerShell/PowerShell |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 49609581 |
| octolytics-dimension-repository_network_root_nwo | PowerShell/PowerShell |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 7aed05249554b889eb33d002851a973eebcc7e91 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width