Im new in PowerShell and working on a script more than 500 lines.
I use the write-host command often. And now Im working on doing the Logging part.
Also, sorry for the bad English.
I want the script to save every write-host command in a .txt,
append and still let the write-host command output passthrough to the Shell output.
Things I tried:
&{
# the script
} *>> $logPath
Start-Transcript -Path $logPath
# the script
Stop-Transcript
It works but its not letting the output passthrough.
# the scriptwithWrite-Host 'Hello World', it writesHello Worldto the display. With PowerShell version and IDE are you using?Tee-Objectcmdlet is designed for this. It passes output both to the console and to a file.