I have a need to grab the stdout from an external program and bring it back into Powershell. I found and am using the answer provided by @Andy Arismendi from this question ( Redirection of standard and error output appending to the same log-file).
The snippet below works great for me, however the external executable runs silently in the background. Is there a way to prevent it from hiding?
$pinfo = New-Object System.Diagnostics.ProcessStartInfo
$pinfo.FileName = "myjob.bat"
$pinfo.RedirectStandardError = $true
$pinfo.RedirectStandardOutput = $true
$pinfo.UseShellExecute = $false
$pinfo.Arguments = ""
$p = New-Object System.Diagnostics.Process
$p.StartInfo = $pinfo
$p.Start() | Out-Null
$p.WaitForExit()
$output = $p.StandardOutput.ReadToEnd()
$output += $p.StandardError.ReadToEnd()
$output | Out-File $myLog -Append