The generally accepted best practice is to use Write-Output for objects that your script is returning, and Write-Verbose for any “screen-only” feedback. If your script’s only output is intended to be on the screen, rather than being assigned to a variable or piped to another command, then you can also just use Write-Output in place of either Write-Host or Write-Verbose. This makes it easy to redirect your script’s output with the redirection operators, Out-File, etc.
system
4
Related topics
| Topic | Replies | Views | Activity | |
|---|---|---|---|---|
| how to get output from write-host into a file | 3 | 558 | April 16, 2019 | |
| Redirect write-host outputs to text file | 8 | 4471 | April 15, 2021 | |
| Using Out-file | 8 | 516 | January 7, 2016 | |
| Unable to capture screen output of a cmdlet in a text file | 12 | 479 | October 30, 2020 | |
| Pipe results to file instead of write-host | 5 | 338 | September 22, 2016 |