Search notes:
Powershell: Param(Parameter(ValueFromPipeline=…)
A parameter that has its
valueFromPipeline
attribute set to
$true
gets its values from the
pipeline (if the command is executed within a pipeline).
A function that has such a
valueFromPipeline
parameter needs to have a
process
block to process the individual objects from the pipeline.
set-strictMode -version 3
function show-piped-objects {
param (
[parameter (valueFromPipeline=$true )] [string] $parameterFromPipeline,
[string] $ordinaryParameter
)
process {
write-host "ordinaryParameter: $ordinaryParameter, parameterFromPipeline = $parameterFromPipeline"
}
}
'foo', 'bar', 'baz' | show-piped-objects -ordinaryParameter XXX