Until PowerShell 4.0,
Write-Host
sends the objects to the host. It does not return any objects.Beginning with PowerShell 5.0 and newer,
Write-Host
is a wrapper forWrite-Information
, which allows to output to the information stream and redirect it with6>> file_name
.
http://technet.microsoft.com/en-us/library/hh849877.aspx
However, if you have a lot of Write-Host
statements, replace them all with Write-Log
, which lets you decide whether output to console, file or event log, or all three.
Check also:
Add-Content
- redirection operators like
>, >>, 2>, 2>, 2>&1
Write-Log
- Tee-Object
Start-Transcript
.