Start-Process: Provide the ability to append when redirecting stdout/stderr streams to file
See original GitHub issueInclude an option/directive for the ‘Start-Process’ cmdlet that allows the user to specify that stream output should be *appended to an existing output file when redirecting the stdout/stderr streams to file.
Currently, when using either the ‘-RedirectStandardOutput’ or ‘-RedirectStandardError’ parameters to specify output file paths for redirection of the standard streams to file, the behavior of ‘Start-Process’ is to create/overwrite if a specified file exists. There is no means to have the output appended to an existing file. This forces the user to come up with additional and, IMHO, seemingly unnecessary work-arounds in order to implement the append logic. This seems like something that could be relatively easily implemented at a lower level, and, quite frankly, seems like basic functionality that the cmdlet should already support.
This could be as simple as adding some kind of append specifier to each parameter:
# stdout files gets overwritten (default behavior), stderr file gets appended to ('>>' specifier)
Start-Process -RedirectStandardOutput='logfile.txt' -RedirectStandardError='>>errlog.txt'
Of course, this could be setup in a variety of ways and/or as the powershell devs see fit.
Justification: There are a variety of cases where it would be useful to be able to have a complete output history of a child process’ output, even when the same child process is created multiple times, or across multiple executions of the parent script/command. Having the ability to append output files directly from ‘Start-Process’ would increase its usefulness in this respect.
Issue Analytics
- State:
- Created 3 years ago
- Comments:9 (3 by maintainers)
Top GitHub Comments
Or maybe even a mode like
-RedirectOutputMode Create/Append
(same for Error). This could have the benefit of addingStore/Var
support where-RedirectStandardOutput
is the name of a variable to redirect the value to.I don’t like an cryptic things in PowerShell language - it is hard for users to discover them. It is more preferable to have an additional switch or two with self described name(s) like -AppendToOutput/-AppendToError.