Script only seems to process the last object from the pipeline Script only seems to process the last object from the pipeline powershell powershell

Script only seems to process the last object from the pipeline


You need to wrap the main body of the script with process{}, this will then allow you to process each item on the pipeline. As process will be called for each item you can even do away with the for loop.

So your script will read as follows:

param(  [parameter(ValueFromPipeline=$true)]  [string]$pipe)process{      Write-Host "Read in " $pipe}

You can read about input processing here: Function Input Processing Methods