You may find it useful at times to record the output of your shell sessions in a log file. This can help you save the history of all the commands you've executed and determine the success or failure of automated scripts. In this recipe, you'll learn how to create a PowerShell transcript.
To create a transcript, perform the following steps:
Execute the
Start-Transcript
cmdlet:Start-Transcript c:\logfile.txt
You can stop recording the session using the
Stop-Transcript
cmdlet:Stop-Transcript
When starting a PowerShell transcript, you can specify a path and a filename that will be used to record your commands and their output. The use of the -Path
parameter is optional; if you do not provide a file path, the cmdlet will create a transcript file with a random name in the default documents folder in your profile path, as shown in the following screenshot:
When you are done, you can run the Stop-Transcript
cmdlet or simply exit...