How can I pass-through parameters in a powershell function?
$args
is not going to pass through arguments correctly. if you want the arguments to remain as separate arguments, you should use @args
instead.
After seeing your comment, option 3 sounds like exactly what you want.
You have a few options:
Use
$args
(credit to hjpotter92's answer)Explicitly define your additional parameters, then parse them all in your function to add them to your perl call.
Use a single parameter with the
ValueFromRemainingArguments
argument, e.g.function global:Test-Multi { Param( [string]$Suite, [parameter(ValueFromRemainingArguments = $true)] [string[]]$Passthrough ) & perl -S "$Suite\runall.pl" -procs:$env:NUMBER_OF_PROCESSORS @Passthrough }
I'm not sure about what you wish to achieve, but the arguments passed to a function are accessible in the $args
variable available inside the function.