title: How can I return a byte array (rather than an Object array) from a PowerShell function
body: <p>I am trying to create a function that return a a byte array (<code>[Byte[]]</code>).</p>
  
  <p>However, when I use the function and assign the returned value to a variable, the type of the variable is an array of objects (<code>[Object[]]</code>).</p>
  
  <pre><code>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)"
  </code></pre>
  
  <p>I am puzzled why that is and would like to know what I can do to force the function to return a byte array.</p>