In Chapter 4, Working with Objects in PowerShell, we started exploring the different output streams 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 will contain the output as it would have been displayed in the console:
PS> Get-Process -Id $pid > process.txt Get-Content process.txt Handles NPM(K) PM(K) WS(K) CPU(s) Id SI ProcessName ------- ------ ----- ----- ------ -- -- ----------- 731 57 132264 133156 1.81 11624 1 powershell_ise
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 | 1 |
Error | 2 |
Warning | 3 |
Verbose | 4 |
Debug | 5 |
Information | 6 |