title: Powershell - How to get all the text output from current session as a string?
body: <p>I have a long script that runs many commands.  These commands print text to the screen via standard output and standard error.  I want to add some logic at the end of the script that takes all text printed to the screen (standard out or standard error) and saves it to a text file.</p>
  
  <p>However, I do <strong>not</strong> want to redirect standard output and standard error to a text file because I want the user of the script to be able to see all the text getting printed to the screen in real time as the script runs.  Indeed, at some points in the script, some of the commands may ask for user input.  Instead, I want to be able to "GetScreenContentsText()" and then write the output of this to the screen.</p>
  
  <p>Is there a way to do this in PowerShell?</p>