Some useful information in advance. What I'm trying to do is read in the output of an external command, in particular steamcmd, using start-process powershell and System.diagnostics.ProcessStartInfo.
What I'm starting up is a limit on the RedirectStandardOutput buffer of 4096 bytes. The output I get from steamcmd is larger than this buffer, so I only get part of what I need. I have no other method to get this data than calling steamcmd.
You can also see the output if you have steamcmd (it is free) and it starts.
steamcmd +login anonymous +app_info_update 1 +app_info_print 443030 +quit
This will download all the manifest information about this application.
I tried to redirect the file, as well as to the variable, and work as expected, just so that it is truncated by the buffer. Also, there is no powershell method in System.Diagnostics.Process to wait for the OutputDataReceived event.
Used code (stolen from another STackOverflow question)
$psi = New-object System.Diagnostics.ProcessStartInfo
$psi.CreateNoWindow = $true
$psi.UseShellExecute = $false
$psi.RedirectStandardOutput = $true
$psi.RedirectStandardError = $true
$psi.FileName = "C:\Path\to\SteamCMD.exe"
$psi.Arguments = "+login anonymous +app_info_update 1 +app_info_print 443030 +quit"
$process = New-Object System.Diagnostics.Process
$process.StartInfo = $psi
[void]$process.Start()
$output = $process.StandardOutput.ReadToEnd()
$process.WaitForExit()
$output
I think the actual problem is that steamCMD just outputs to one big record instead of line by line. I think the best question would be how can I increase the size of the standard output buffer for Start-Process or System.Diagnostics.Process.
Note: running steamcmd> somefile.txt results in the same buffer limit.
source
share