Recording the Commands and Output of a PowerShell Session to a text file in PowerShell 2.0

Hi All,

There may be times where you would like to record a PowerShell session to a text file so you can go back and review what you have done later. This can be useful when working on an issue or using PowerShell to change configurations. It will make it easy if you need to go back to see what you have changed as well as the output that came along with issuing the commands for those changes. The cmdlet that is used to start recording your session is the “Start-Transcript” command.

If you would like to start a transcript and log it to a file called “PSTranscript.txt” in a directory named “C:\PowerShellTranscript” you can type the following:

start-transcript C:\PowerShellTranscipt\PSTranscript.txt

After you type the above command you will receive confirmation that the transcript has started. Now every thing you type as well as all output will be logged to this file. Even if you type something in error it will be recorded as will the error message.

When you are finished recording the session you can simply type the following:

Stop-Transcript

You will then receive confirmation that the transcript has stopped and it will tell you the path to the output file.

If you need more information on how to use the Start-Transcript cmdet you can use the help file by simply typing “Get-Help Start-Transcript”. Hope this helps. If you have any questions or feedback please leave a comment. Thanks.

Related Links:

Getting Started With PowerShell 2.0

Using the Show-Command cmdlet in PowerShell 3.0

Using the Server Manager Module in PowerShell to Install Roles and Features On a Windows Server

Leave a Reply

Your email address will not be published. Required fields are marked *