Start-Process should support redirecting to variable names or stream objects
See original GitHub issueBecause there are many executables (mostly of linux origin) which use stderr to write status messages (in addition to errors), and rely purely on exit code to indicate whether there actually is an error or not …
As a PowerShell scripter, I need to be able to run an executable and both stream the output for sake of status updates and capture the (stderr) output so I can report on it properly if there is an actual error.
Start-Process doesn’t support this – it only captures to file, and if it does, it doesn’t output. Additionally, since output stream redirection is limited to redirecting to stdout
or file, I cannot redirect error to verbose on CLI apps that consistently behave this way…
My current company has contrived more than one complicated wrapper around ProcessStartInfo
and Diagnostics.Process
to handle the output events and so on. In fact, it seems that every company I work with above a certain level of PowerShell maturity has their own custom Invoke-Process
or other replacement for Start-Process to try and handle this.
Start-Process should allow capturing and also outputting
Start-Process should allow capturing (and reading input from) variables instead of just files
Issue Analytics
- State:
- Created 6 years ago
- Reactions:8
- Comments:5 (3 by maintainers)
Personally, I think we should not enhance
start-process
and instead provide ways to solve interacting with processes natively. It seems that if we make the Variable: provider work like a file, this should solve some of your problems?Tee-Object
doesn’t work with redirection, so need to think how to redirect while still outputting…We should also allow redirecting one stream to another stream beyond stdout like:
P.S: Asking for the ability to capture stderr lines in a variable is the subject of #4332