Question Details

No question body available.

Tags

powershell transcription interactive-transcript

Answers (1)

Accepted Answer Available
Accepted Answer
July 5, 2025 Score: 4 Rep: 401 Quality: High Completeness: 80%

You have done nothing wrong here.
The example you used as source is meant to be run directly in the console, not in a script (and it would be better if it mentioned that).
The issue is this:

I have this code at the start of a long script

When you check the actual description of the $Transcript variable, you'll find the following:

$Transcript
[...] If you don't specify a value for the Path parameter, Start-Transcript uses the path in the value of the $Transcript global variable. [...]

The $Transcript variable in your script is (by default) defined in the Script scope, not the Global scope, so Start-Transcript won't use it and fall back to the default path.

Defining $Transcript as global variable will work:

$Global:Transcript = (Join-Path -Path $Path -ChildPath $filename).ToString()

You should also then always include the scope if you're using it later in the script.

Or, as @iron suggested, just use the Path or LiteralPath parameters.