Output file doesn’t match Write-Host

Caveat: Write-Host is meant for to-display output, not for outputting data – it bypasses PowerShell’s success output stream (PowerShell’s stdout equivalent), so that output from Write-Host cannot (directly[1]) be captured in a variable, nor redirected to file – see the bottom half of this answer for more information. Use Write-Output or – preferably – PowerShell’s … Read more

redirecting test-path output to text file

To complement Zam’s helpful answer with background information: Write-Host writes to the host[1] (typically, the console aka terminal), which bypasses PowerShell’s success output stream and therefore sends nothing trough the pipeline. See the bottom section of this answer for when Write-Host is appropriate; in short: you should generally only use it for display-only output. Write-Output … Read more