I am trying to wrap my head around parameter sets. It seems fairly straight forward up until the point where you need to be able to use A or B, or both A & B. I need to essentially be able to say that out of two parameters, at least one must be provided.
This is an example of the code that I am currently using (without parameter sets), but this would allow for nothing but $c to be passed.
Function Test-Params
{
Param
(
[string[]]
$a,
[string[]]
$b,
[Parameter(Mandatory=$true)]
[string]
$c
)
}
Is there a way to handle this with parameter sets, or is it more appropriate to perform some form of validation within the function?
I would like for the following to be accepted:
Test-Params -a $arr_a -c "C:\test.txt"
Test-Params -b $arr_b -c "C:\test.txt"
Test-Params -a $arr_a -b $arr_b -c "C:\test.txt"