Title: A common `-Tee` parameter · Issue #20133 · PowerShell/PowerShell · GitHub
Open Graph Title: A common `-Tee` parameter · Issue #20133 · PowerShell/PowerShell
X Title: A common `-Tee` parameter · Issue #20133 · PowerShell/PowerShell
Description: Summary of the new feature / enhancement A common -Tee parameter for outputting the processed item and passing through the original input item. This feature request is a follow up of #19989 Currently: The -PassThru switch is based on ind...
Open Graph Description: Summary of the new feature / enhancement A common -Tee parameter for outputting the processed item and passing through the original input item. This feature request is a follow up of #19989 Current...
X Description: Summary of the new feature / enhancement A common -Tee parameter for outputting the processed item and passing through the original input item. This feature request is a follow up of #19989 Current...
Opengraph URL: https://github.com/PowerShell/PowerShell/issues/20133
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"A common `-Tee` parameter","articleBody":"### Summary of the new feature / enhancement\r\n\r\n**A common -Tee parameter for outputting the processed item and passing through the original input item.**\r\n\r\nThis feature request is a follow up of #19989\r\nCurrently:\r\n* The `-PassThru` switch is based on individual cmdlets and therefore isn't commonly available and consistently implemented.\r\n* The `Tee-Object` cmdlet is able to tee the current object but is limited to a specific output (or a *new* pipeline as purposed in #20123)\r\nIn my believe every (advanced) function/cmdlet that has a `ValueFromPipeline` input (\u003cstrike>and has no success stream pipeline output\u003c/strike>¹), should have (an easy standard way to implement) a common way to pass the current input item using a `-Tee` parameter.\r\n\r\n1) Any output passed to the success stream should be redirected to the information stream (similar to what usually happens at the end of pipeline) and the original input item/object should be placed back into the success stream. This allows me to do thinks along with (wishful thinking):\r\n`... | Format-Table -Tee | ...`\r\nOr something more sophisticated with the current stage:\r\n`... | Foreach-Object { Write-Host \"Processing: $($_.Name)\" } -Tee | ...`.\r\n\u003csub>(I think this need a deeper thoughts as this opens the possibility to recurse a `-Tee` which has some similarities -and pitfalls?- with the common [`-PipelineVariable`](https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_commonparameters#-pipelinevariable) parameter)\u003c/sub>\r\n\r\nTake e.g.: [Powershell - Get IP Addresses for hostnames from File (more than 150K hostnames)](https://stackoverflow.com/questions/76702673/powershell-get-ip-addresses-for-hostnames-from-file-more-than-150k-hostnames)\r\n\r\nThe `Export-Csv` appears not be [written for the middle of the pipeline](https://learn.microsoft.com/powershell/scripting/developer/cmdlet/strongly-encouraged-development-guidelines#implement-for-the-middle-of-a-pipeline) and doesn't support the `-PassThru` parameter:\r\n\r\n> Export-Csv: A parameter cannot be found that matches parameter name 'PassThru'.\r\n\r\nBut I see no reason why these type of cmdlets shouldn't have a possibility to pass the current input item.\r\nWishful thinking:\r\n\r\n```PowerShell\r\n... | Export-Csv .\\test.csv -Tee | Format-Table\r\n```\r\n\r\nThis way you might [avoid wrapping a new cmdlet pipelines](https://learn.microsoft.com/powershell/scripting/dev-cross-plat/performance/script-authoring-considerations#avoid-wrapping-cmdlet-pipelines) to continue with the current input item.\r\n","author":{"url":"https://github.com/iRon7","@type":"Person","name":"iRon7"},"datePublished":"2023-08-17T16:29:36Z","url":"https://github.com/PowerShell/PowerShell/issues/20133"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| 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:92a2901a-438e-8689-7a26-c164eed9f311 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C742:3A3F7F:175ED1:21735B:6AFD5DA9 |
| html-safe-nonce | 44a17f7c7d71733473fc0d3182df448d17c7eeedc521829814a5b82910d41307 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDNzQyOjNBM0Y3RjoxNzVFRDE6MjE3MzVCOjZBRkQ1REE5IiwidmlzaXRvcl9pZCI6IjQ2OTI0NTE2ODE5Mjc3ODE4MDEiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 3cdd0d3f1a6e832c1e7bcff4b4a6525f37742454738bc8b855fd5442c938d774 |
| hovercard-subject-tag | issue:1855329877 |
| 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/20133/issue_layout |
| twitter:image | https://opengraph.githubassets.com/6e5dc9de4511e921d8dfb03360a748482e577075d7784c0937570466345db2b7/PowerShell/PowerShell/issues/20133 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/6e5dc9de4511e921d8dfb03360a748482e577075d7784c0937570466345db2b7/PowerShell/PowerShell/issues/20133 |
| og:image:alt | Summary of the new feature / enhancement A common -Tee parameter for outputting the processed item and passing through the original input item. This feature request is a follow up of #19989 Current... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | iRon7 |
| hostname | github.com |
| expected-hostname | github.com |
| None | 66653c2e55a6fff2930be1bdf07ee4f8aa137e3956d056c822563be6f878755e |
| 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 | b6f01f7cb9f35f8c09949773241a3d49dd04b340 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width