I'm looking for a way to read bytes from stdin and pass them to stdout. I've found this question which talks about how to read from stdin using text encoding. I want read and write using raw or binary encoding.
Getting stdin into the Powershell stream
The question says it is non-trival to deal with decoding and encoding. If it helps this is the way I am doing this in VBScript:
Do While Not WScript.StdIn.AtEndOfStream
WScript.StdOut.Write(WScript.StdIn.Read(1024))
Loop
This following does not work because the encoding is wrong. I'm using redirection just for illustrative purposes. I need to be able to read from stdin.
powershell -NoProfile -Command "$Input" <file1.exe >file2.exe