Start Transcript - PowerShell


Overview

Start-Transcript initiates a PowerShell transcript session, capturing all subsequent commands and their outputs into a text file for documentation or logging purposes.

Syntax

Start-Transcript [-Path] <string> [-Append] [-NoClobber] [-Force] [-Encoding <Encoding>] [-NoBps] [-NoLink] [-InputFile <string>] [-OutputFile <string>]

Options/Flags

  • -Path: Specifies the path and filename where the transcript will be saved. By default, it saves to the current directory as “PowerShell_transcript.txt”.
  • -Append: Appends the transcript to an existing file instead of overwriting it.
  • -NoClobber: Prevents overwriting an existing transcript file.
  • -Force: Overwrites an existing transcript file without prompting for confirmation.
  • -Encoding: Sets the character encoding of the transcript file. Default is Unicode (UTF-16). Other options include ASCII, UTF-7, UTF-8, UTF-32.
  • -NoBps: Disables byte-order mark (BOM) in the transcript file. BOM is required by some non-Unicode encodings.
  • -NoLink: Does not create a link to the transcript file in the console window.
  • -InputFile: Specifies the source file containing commands to run and transcript.
  • -OutputFile: Specifies the destination file name and path to save the transcript.

Examples

Example 1: Start a new transcript in a specific file:

Start-Transcript -Path "C:\MyTranscript.txt"

Example 2: Append to an existing transcript:

Start-Transcript -Path "ExistingTranscript.txt" -Append

Example 3: Run a script and transcript it:

Start-Transcript -InputFile "MyScript.ps1" -OutputFile "MyScriptTranscript.txt"

Common Issues

  • Empty transcript file: Ensure the transcript file has not been deleted or moved. If the transcript is not created, check the path and file name.
  • Unauthorized access error: Verify that the user has write permissions to the specified path.

Integration

Get-Transcript: Retrieve the contents of a transcript session.
Stop-Transcript: End a transcript session.
Write-Host: Write text directly to the transcript without running a command.