PowerTip: Use PowerShell to Save Verbose Messages in Output File

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

Comments (7)

  1. Boe Prox says:


    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.

  2. coooly says:

    Why not using a more powershell friendly solution like start-transcript ?

  3. Eugenio Miró says:

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

  4. Frederic says:

    In my case the created file is empty

  5. Graham says:

    Thanks, I’ve been searching for a way of logging all verbose output as an extended log. Only thing… I want to change the width of the output before it goes to file. My log file is only 80 chars long forcing new lines. Anyone know how to do that ?

  6. tiger says:

    Doesn’t work for

    Start-Job {$VerbosePreference = ‘Continue’; Write-Verbose 123 -Verbose} | Wait-Job | Receive-Job 4>C:junk.txt

Skip to main content