Tworzenie Byte [] w PowerShell

Mam jakiś kod PowerShell, który używa interfejsu API COM. Otrzymuję błąd niezgodności typu, gdy przekazuję tablicę bajtów. Oto jak tworzę tablicę, a także informacje o typie

PS C:\> $bytes = Get-Content $file -Encoding byte
PS C:\> $bytes.GetType()

IsPublic IsSerial Name                                     BaseType
-------- -------- ----                                     --------
True     True     Object[]                                 System.Array


PS C:\> $bytes[0].GetType()

IsPublic IsSerial Name                                     BaseType
-------- -------- ----                                     --------
True     True     Byte                                     System.ValueType

Przeszukując API, odkryłem, że szuka Byte [] z typem bazowym System.Array.

PS C:\> $r.data.GetType()

IsPublic IsSerial Name                                     BaseType
-------- -------- ----                                     --------
True     True     Byte[]                                   System.Array

PS C:\> $r.data[0].gettype()

IsPublic IsSerial Name                                     BaseType
-------- -------- ----                                     --------
True     True     Byte                                     System.ValueType

Próbuję przekonwertować $ bajtów na ten sam typ co $ r.data. Z jakiegoś powodu $ bajty są tworzone jako obiekt []. Jak mogę go rzucić na Byte []?

questionAnswers(3)

yourAnswerToTheQuestion