Use process block for pipeline inputs (PS)

If you get a parameter via the pipeline and don’t use a process block, you will operate just on the last input.

function PrintFromPipeline {
    param (
        [Parameter(ValueFromPipeline)] [string[]] $InputObject
    )

    foreach ($Item in $InputObject) {
        Write-Output $Item
    }
}
'1', '2', '3' | PrintFromPipeline
# 3

You don’t even need the foreach loop, cause the process block will be executed for every pipeline input.

function PrintFromPipeline {
    param (
        [Parameter(ValueFromPipeline)] [string[]] $InputObject
    )

    process {
        Write-Output $InputObject
    }
}
'1', '2', '3' | PrintFromPipeline
# 1
# 2
# 3