command > filename Redirect command output to a file (overwrite) command >> filename APPEND into a file command 2> filename Redirect Errors from operation to a file(overwrite) command 2>> filename APPEND errors to a file command 2>&1 Add errors to results command 1>&2 Add results to errors command | command This is the basic form of a powershell Pipeline
In powershell it is not possible to redirect the output of an entire session (so Powershell.exe .... >filename.txt won't work) however a very similar text output can be produced using the Start-Transcript cmdlet.
The text files produced by powershell are (by default) in Unicode, if you need a different encoding, use Out-File instead of the redirection operator.
Examples
PS C:\>Get-ChildItem c:\windows\system >> "c:\my logs\text1.txt"
PS C:\>Get-ChildItem c:\windows\system | Out-File text2.txt -encoding ASCII
PS C:\>Start-Transcript -path c:\docs\Text3.txt
...
PS C:\>Stop-Transcript
“Most variables can show either an upward trend or a downward trend, depending on the base year chosen” - Thomas Sowell
Related:
Tee-Object - Send input objects to two places
Start-Transcript - Start a transcript of a command shell session
Stop-Transcript - Stop the transcription process