Answer the question
In order to leave comments, you need to log in
How can I specify one required argument and an unlimited number of optional ones in a function?
There is a function
Function foo($a) {
echo $a
echo $args
}
Function foo {
param(
[Parameter (Mandatory = $true, Position = 0)] $a
)
echo $a
echo $args
}
Answer the question
In order to leave comments, you need to log in
and so?
Function foo {
param(
[Parameter (Mandatory = $true, Position = 0)] $a,
[Parameter (ValueFromRemainingArguments)] $other_params
)
"a:"
$a
"other params:"
$other_params
}
foo "param1" "param2" "param3" "param4" "param5" "param6"
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question