arrays – Creating Byte[] in PowerShell
arrays – Creating Byte[] in PowerShell
This answer is for the question with no context. Im adding it because of search results.
[System.Byte[]]::CreateInstance([System.Byte],<Length>)
In PS 5.1, this:
[System.Byte[]]::CreateInstance(<Length>)
didnt work for me. So instead I did:
new-object byte[] 4
which resulted in an empty byte[4]:
0
0
0
0
arrays – Creating Byte[] in PowerShell
Cast it to a byte array:
[byte[]]$bytes = Get-Content $file -Encoding byte