Search code examples
powershellloggingtranscription

How to automatically save PowerShell session


How can i redirect everything what happens within a PowerShell windows (inputs and outputs) automatically to a file? I don't mean single commands instead i would like to have something like a logger which captures everything and logs into a local file so that i have a history of things done within the powershell window.


Solution

  • You're looking for PowerShell's Start-Transcript cmdlet, which:

    creates a record of all or part of a Windows PowerShell session to a text file. The transcript includes all command that the user types and all output that appears on the console.

    Running transcripts must be stopped explicitly, with the Stop-Transcript cmdlet.