Powershell logging example or how to redirect output to file by using Write-Output

Posted on

Few days I got a simple question from one of blog readers regarding how to log in powershell .

In order to redirect your output to file you need to execute script and indicate that output source is file

PS C:\> prototypes\logging.ps1 |Out-File C:\prototypes\ps.log

In your script use command Write-Output to write anything to your current output 🙂

Write-Output “Test”


  • Km Tatar

    Hi,
    how to logging all commands in powershell to file ?