Does someone know why Mandatory attribute on parameter $a affects the type casting behaviour of parameter $b? In the example the array should be cast to a string.
function test ([Parameter(Mandatory = $True)] [string] $a, [string] $b) {
$a; $b
}
$b = "a", "b", "c"
test -a "my string" -b $b
When this code chunk is executed it produces error: test : Cannot process argument transformation on parameter 'b'. Cannot convert value to type System.String. At line:1 char:31
If I remove the Mandatory attribute from $a it works fine:
function test ([string] $a, [string] $b) {
$a; $b
}
$b = "a", "b", "c"
test -a "my string" -b $b
Thanks in advance for feedback