You're using the pipeline (|
) to provide input to Out-File
.
Only stream 1
, the success (data) output stream is sent through the pipeline by default.
The conceptual about_Redirection help topic, from which you quote, documents all 6 PowerShell streams.
Optionally - as you have done - you can merge other streams into stream 1
, which causes their output to be included as well.
You can merge:
individual streams by their number; e.g. 3>&1
merges the warning stream (3
) into the success stream; multiple such redirections may be used.
all (other) streams, represented by *
, i.e. by using *>&1
Since you are using *>&1
, output from all streams is sent through the pipeline and therefore saved to the target file by Out-File
.
As an aside: >
, the redirection operator (along with >>
), is an effective alias of Out-File
, so you can use it alone to save to a file - assuming Out-File
's default character encoding is acceptable:[1]
& { 'success'; Write-Warning 'warning' } *> allstreams.txt
Targeting files with >
also allows you to save individual streams to separate files:
& { 'success'; Write-Warning 'warning' } > data.txt 3> warnings.txt
[1] In PowerShell version 5.1 and above you can change Out-File
's default encoding in a manner that also takes effect for >
, via the preference variable $PSDefaultParameterValues
- see this answer.