-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Description
The about_Parameters
, about_Functions_Advanced_Parameters
and about_Script_Blocks
topics state:
The former two:
A parameter that accepts pipeline input (by Value) will enable use of delay-bind script blocks on all other parameters defined to accept pipeline input.
The latter:
A delay-bind script block allows you to pipe input to a given parameter, then use script blocks for other parameters using the pipeline variable $_ to reference the same object.
This is incorrect in two respects:
- It is not necessary for multiple pipeline-binding parameters to be present - one is enough.
- Specifically, there is no requirement that a by-value (as opposed to by-property-name) parameter be present.
In short: While it may be the typical uses case that the pipeline input binds to a by-value parameter and that additional parameters may be bound by delay-bind script blocks, that is not a requirement.
Here's an example:
'foo', 'bar' | & {
param(
[Parameter(ValueFromPipelineByPropertyName)]
[string] $Text
)
process {
"[$Text]"
}
} -Text { $_ + '!' }
The above yields:
[foo!]
[bar!]
which showsthat a single, by-property-name pipeline-binding parameter is sufficient to support delay-binding.
Version(s) of document impacted
- Impacts 6.next document
- Impacts 6 document
- Impacts 5.1 document
- Impacts 5.0 document
- Impacts 4.0 document
- Impacts 3.0 document