Logging shell sessions to a transcript

You may find it useful at times to record the output of your shell sessions in a logfile. 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.

How to do it...

  1. To create a transcript, execute the Start-Transcript cmdlet:
    Start-Transcript -Path c:\logfile.txt
    
  2. You can stop recording the session using the Stop-Transcript cmdlet:
    Stop-Transcript
    

How it works...

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, ...

Get Microsoft Exchange Server 2013 PowerShell Cookbook - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.