The easiest way would be to place this line at the beginning of the script.

 Code:
$nul = RedirectOutput("C:\path\to\file\log.txt")


Essentially this will cause any message that normally displays on the console, to be instead saved to the file.