title: How do I pipe a byte stream to/from an external command?
body: <p>With <a href="https://docs.microsoft.com/powershell/module/microsoft.powershell.management/get-content#code-try-8" rel="nofollow noreferrer"><code>Get-Content -AsByteStream</code></a>, one can read file as a byte stream.</p>
  <p>With <a href="https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.management/set-content#parameters" rel="nofollow noreferrer"><code>Set-Content -AsByteStream</code></a>, one can create a file from a byte stream.</p>
  <p>However, I can't find any way to pass these byte streams to other non-PowerShell command. Pipes between external commands always decode data as String, mangling binaries.</p>
  <p><a href="https://stackoverflow.com/a/44193983/188256"><code>cmd /c --%</code></a> or <a href="https://stackoverflow.com/a/60392751/188256"><code>Start-Process -RedirectStandardInput</code></a> do solve part of the problem, but it can get a bit tedious if any of involved command is another cmdlet. Is there a PowerShell-native way to handle executable input/output as a stream of byte?</p>