I have a script that I'm trying to add pipeline functionality to. I'm seeing the strange behavior, though, where the script seems to only be run against the final object in the pipeline. For example
param(
[parameter(ValueFromPipeline=$true)]
[string]$pipe
)
foreach ($n in $pipe) {
Write-Host "Read in " $n
}
Dead simple, no? I then run 1..10 | .\test.ps1
and it only outputs the one line Read in 10
. Adding to the complexity, the actual script I want to use this in has more to the parameters:
[CmdletBinding(DefaultParameterSetName="Alias")]
param (
[parameter(Position=0,ParameterSetName="Alias")]
[string]$Alias,
[parameter(ParameterSetName="File")]
[ValidateNotNullOrEmpty()]
[string]$File
<and so on>
)