You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
On top of #19989, add -Format parameter to Write-Host #20121
I don't get, how would it differ from just Write-Host "Processing: $_"?
You can't put that in the middle of a pipeline as it accepts only an inputobject from the pipeline or a parameter and it writes by default to the information stream, e.g.:
But you're talking about Write-Host -PassThru which is another proposal. What I'm asking is: if Write-Host -PassThru exists, how will 1,2,3 | Write-Host -PassThru -Format "Processing: $_" | Set-Content .\test.txt differ from 1,2,3 | Write-Host -PassThru "Processing: $_" | Set-Content .\test.txt.
If this -Format switch would be required to properly anchor $_, I think you'd be better of with any of the following for this specific usecase, as they achieve the same exact thing and are either already possible or IMO easier to implement:
how will 1,2,3 | Write-Host -PassThru -Format "Processing: $_" | Set-Content .\test.txt differ from ...
Just to be clear:
Just 1,2,3 | Write-Host "Processing: $_" (currently) produces an error: Write-Host: The input object cannot be bound to any parameters for the command either because the command does not take pipeline input or the input and its properties do not match any of the parameters that take pipeline input.
(meaning that you need to create an additional parameter if you want to use the value-from-pipeline)
Write-Host doesn't currently output to the success stream but directly to the information stream (host)
For all (different) implications, the -PassThru parameter causes a cmdlet that doesn't output to the success stream
For your suggestions that embed a cmdlet in a ScriptBlock ({ ... }), that is one of the reasons for my initial purpose as this would involve a complete new pipeline with the overhead of all (Begin, End) processing blocks.
This would not be always necessarily, e.g. something like this:
iRon7, I understand your intent, but as an aside: "Processing: $_" could never work, because it would be expanded up front, at which point $_ has no meaningful value, so perhaps you meant 'Processing: $_' (single-quoting), or, more idiomatically, { "Processing: $_" }.
Activity
mklement0 commentedon Aug 16, 2023
This too sounds like it could be addressed with Dominik Kowalski (@dkaszews)' yet-to-be-fully-fleshed-out
Tee-Object -Process { ... }proposal:-PassThruas common parameter #19989 (comment)dkaszews commentedon Aug 16, 2023
I don't get, how would it differ from just
Write-Host "Processing: $_"?iRon7 commentedon Aug 16, 2023
Dominik Kowalski (@dkaszews),
You can't put that in the middle of a pipeline as it accepts only an inputobject from the pipeline or a parameter and it writes by default to the information stream, e.g.:
dkaszews commentedon Aug 16, 2023
But you're talking about
Write-Host -PassThruwhich is another proposal. What I'm asking is: ifWrite-Host -PassThruexists, how will1,2,3 | Write-Host -PassThru -Format "Processing: $_" | Set-Content .\test.txtdiffer from1,2,3 | Write-Host -PassThru "Processing: $_" | Set-Content .\test.txt.If this
-Formatswitch would be required to properly anchor$_, I think you'd be better of with any of the following for this specific usecase, as they achieve the same exact thing and are either already possible or IMO easier to implement:iRon7 commentedon Aug 17, 2023
Dominik Kowalski (@dkaszews),
Just to be clear:
1,2,3 | Write-Host "Processing: $_"(currently) produces an error:Write-Host: The input object cannot be bound to any parameters for the command either because the command does not take pipeline input or the input and its properties do not match any of the parameters that take pipeline input.(meaning that you need to create an additional parameter if you want to use the value-from-pipeline)
Write-Hostdoesn't currently output to the success stream but directly to the information stream (host)-PassThruparameter causes a cmdlet that doesn't output to the success streamFor your suggestions that embed a cmdlet in a ScriptBlock (
{ ... }), that is one of the reasons for my initial purpose as this would involve a complete new pipeline with the overhead of all (Begin,End) processing blocks.This would not be always necessarily, e.g. something like this:
or in this add-on purpose:
Could have a nicer syntax and presumably preforms better if it could be written as (follow up issue #20133):
or in this add-on purpose (which still might be useful at the end of the pipeline):
mklement0 commentedon Aug 18, 2023
iRon7, I understand your intent, but as an aside:
"Processing: $_"could never work, because it would be expanded up front, at which point$_has no meaningful value, so perhaps you meant'Processing: $_'(single-quoting), or, more idiomatically,{ "Processing: $_" }.iRon7 commentedon Aug 18, 2023
Michael Klement (@mklement0),
Yes, you're right.
Anyways, I will close this "add-on" propose as it is now covered by my new updated purpose #20133;
mklement0 commentedon Aug 19, 2023
Sounds good, iRon7; on a quick meta note: the words you're looking for are "proposal" (as a noun) and "propose" (as a verb).