I am trying to create a function that return a a byte array ([Byte[]]).
However, when I use the function and assign the returned value to a variable, the type of the variable is an array of objects ([Object[]]).
function make-byteArray() {
[OutputType([Byte[]])]
[byte[]] $byteArray = new-object byte[] 2
$byteArray[0] = 0
$byteArray[1] = 1
write-host "type of byteArray: $($byteArray.GetType().FullName)"
return $byteArray
}
$x = make-byteArray
write-host "type of x: $($x.GetType().FullName)"
I am puzzled why that is and would like to know what I can do to force the function to return a byte array.