Hi!
Strange thing.
I have the next function:
function TestFunc {
param ([Parameter(Mandatory)][string[]] $array)
Write-Host $array
}
So, if I try to execute the next code:
$arr = @("test1", "", "test2")
TestFunc $arr
I’ve got the error:
Cannot bind argument to parameter ‘array’ because it is an empty string
But if, I specify the AllowEmptyString() like this:
function TestFunc {
param ([Parameter(Mandatory)] [AllowEmptyString()] [string[]] $array)
Write-Host $array
}
all works fine.
So, I tried to send the whole array to function, why does only one empty array element cause the error above ?
Could somebody explain this behavior