Function foo{
[CmdletBinding()]
Param(
[Parameter(ValueFromPipeline, ValueFromPipelineByPropertyName)]
[array]$path
#[string[]]$path #I tried this too, same issue as above.
)
Begin{"---begin---" ; $path}
Process{"---Process---" ; $path}
End{"---End---" ; $path}
}
without the pipeline, multiple values passed to the path
parameter are always seen as a multi line string, foo -path 'C:tempgreen', 'C:tempblue', 'C:tempred'
:
---begin---
red
blue
green
---Process---
red
blue
green
---End---
red
blue
green
with the pipeline, values to path
are correctly treated as array elements, foo -path 'red', 'blue', 'green'
:
---begin---
---Process---
red
---Process---
blue
---Process---
green
---End---
green
I dont understand this sudden change of behaviour, I am expect both instances of invoking foo
(with or without pipeline) to output values to path
as single array elements.
win11/pwsh 7.4