Is it possible to get Powershell to read the stdout of an exe into a byte[] instead of the usual text processed array of lines?
Best I've been able to do is this:
cmd 开发者_C百科/c foo.exe > foo.tmp
$b = [io.file]::readallbytes('foo.tmp')
del foo.tmp
Yucky, not to mention it is not streamable. Any better way to do this?
Got some info from the PowerShell team. The short answer is that unfortunately, it is not easy. :-(
The medium length answer is: http://poshcode.org/2175.
The long answer is: Capture and Redirect Binary Process Output
精彩评论