October 2017
Intermediate to advanced
440 pages
11h 47m
English
Streams can be redirected to standard output in PowerShell. The destination stream is written on the right-hand side of the redirect operator (without a space). Stream numbers on the right-hand side are prefixed with an ampersand (&) to distinguish the stream from a filename.
For example, the Information output written by the following command is sent to standard output:
PS> function Test-Redirect{ 'This is standard out' Write-Information 'This is information'}$stdOut = Test-Redirect 6>&1$stdOutThis is standard outThis is information
It is possible to redirect additional streams, for example, warnings and errors, by adding more redirect statements. The following example redirects the error and warning ...
Read now
Unlock full access