title: write all console output to a file at end of script
body: <p>i have a long script that checks at different parts of the script for things like connection, csv file created, data updated, etc...</p>
  
  <p>so essentially looks like this:</p>
  
  <pre><code>write-host "connection successful!"
  #50 lines later of some code doing stuff ...
  write-host "csv file created!"
  #more code here doing stuff
  write-host "data updated!"
  </code></pre>
  
  <p>now instead of redirecting output at every single write-host/console output to a file, is there a way i can simply copy console output to a file at once at the end of the script?</p>
  
  <p>pseudocode of what i want:</p>
  
  <pre><code>direct ALL console outputs to file ./log.txt
  </code></pre>