PowerShell - Reading Binary Data

Tue Jan 04 2022Programming

The first version is compatible with PowerShell 6:

# Solution 1 (PowerShell 6)
Get-Content -Path D:\mytest.zip -Encoding Byte

The second version is compatible with PowerShell 7:

# Solution 2 (PowerShell 7)
Get-Content D:\mytest.zip -AsByteStream

However for a version that works equally well between both, simply invoke the beautiful power of C# and do away with the hassle!

# Solution 3 - Use C# (PowerShell 6/7 Compatible)
[System.IO.File]::ReadAllBytes("D:\mytest.zip")
GatsbyNetlifyReactTypeScriptTailwind CSS
© Copyright 2008-2022 Terry Butler