The $args variable should, by definition, contain all arguments passed to a script function. However if I construct a pipeline inside my function, the $args variable evaluates to null. Anyone knows why?
See this example:
function test { 1..3 | % { echo "args inside pipeline: $args" } ; echo "args outside pipeline: $args" }
This is the output, when passing parameter "hello":
PS> test hello
args inside pipeline:
args inside pipeline:
args inside pipeline:
args outside pipeline: hello
Is there a specific reason for this? I know how to work around this, however I wonder if anonye out there can explain the reason for this.