EDIT and answer:
Turns out I was wrong believing that the error generated by ValidateScript would terminate the whole pipeline.
My tests on this behavior were incomplete and led me to believe that the result would be the same as a terminating error generated inside a PROCESS code block (which terminates the whole pipeline).
Let’s say I write a function that gets a path via a parameter ($Path) and do something with it.
Usually, I’ll use the handy “ValidateScript” parameter attribute to ensure that the path is valid.
But, if the function is written in a “pipelined” form (BEGIN, PROCESS, END) and can get the value of $Path via pipeline (“ValueFromPipelinebyPropertyName”), the entire pipeline will terminate at the first invalid $Path it encouters (because “ValidateScript” generates a terminating error).
What would be the best practice to validate values obtained in a pipeline without terminating the entire pipeline? So, If the pipeline receives an invalid path, it displays a (non terminating) error message and just moves on to the next object.
I managed to get this kind of behavior with a “try-catch” inside the PROCESS code block but it can get very complicated if the function can get more than 1 of its parameters via a pipeline.
Am I missing a better way to do this?