Redirection operators
Chapter 4, Working with Objects in PowerShell, started exploring the different output streams that PowerShell utilizes.
Information from a command may be redirected using the redirection operator, >. Information may be sent to another stream or a file.
For example, the output from a command can be directed to a file. The file contains the output as it would have been displayed in the console:
PS> Get-Process -Id $pid > process.txt
PS> Get-Content process.txt
NPM(K) PM(M) WS(M) CPU(s) Id SI ProcessName
------ ----- ----- ------ -- -- -----------
78 144.69 186.91 12.69 15284 1 pwsh
Each of the streams in PowerShell has a number associated with it. These are shown in the following table:
|
Stream name |
Stream number |
|
Standard out |
... |