Erstellen von Byte [] in PowerShell
Ich habe PowerShell-Code, der eine COM-API verwendet. Beim Übergeben eines Bytearrays wird ein Typenkonfliktfehler angezeigt. Hier ist, wie ich das Array erstelle, sowie einige Typinformationen
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
Beim Stöbern mit der API habe ich festgestellt, dass nach einem Byte [] mit dem Basistyp System.Array gesucht wird.
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
Ich versuche $ bytes in den gleichen Typ wie $ r.data umzuwandeln. Aus irgendeinem Grund wird $ bytes als Objekt [] erstellt. Wie kann ich es in ein Byte [] umwandeln?