I need to log everything printed to stdout to a file. Start-Transcript/Stop-Transcript works great and does exactly this, but only for the local PowerShell sessions. The problem is that Transcripts are not supported when executing PowerShell scripts in a remote session (using Enter-PSSession cmd).
Is there another (preferably simple) way to redirect all output to a file, even if the .ps1 script is executed in a remote session?
I'd prefer not to have to add >> or Tee or out-file etc. to every line in the script that has output.
I also do not want to Start-Transcript before entering the remote session. I'm remoting to many destinations in a loop and I need each remote session's stdout logged to a separate file (local to the endpoint), not all bundled into a single file.