PowerTip: Use PowerShell to Save Verbose Messages in Output File

PowerTip: Use PowerShell to Save Verbose Messages in Output File

  • Comments 4
  • Likes

Summary: Learn how to use Windows PowerShell to save verbose messages from a script in an output file.

Hey, Scripting Guy! Question How can I use Windows PowerShell to save the verbose messages from a script in an output file?

Hey, Scripting Guy! Answer Use the redirection operator that directs verbose messages (stream #4) to a file:

PS C:\> .\MyScript.ps1 -Verbose  4> VerboseMessages.txt

Your comment has been posted.   Close
Thank you, your comment requires moderation so it may take a while to appear.   Close
Leave a Comment
  • Why not using a more powershell friendly solution like start-transcript ?

  • @Coooly

    Start-Transcript will log everything during the console session (including the prompt), not just a specific stream. By doing it the way mentioned in this example, you are just grabbing a specified stream.

  • And how do I change the encoding of the Verbose Output?

  • In my case the created file is empty