PowerShell Transcript: Log Everything Your Session Does

When a compliance team asks “what exactly did that script do on Tuesday?”, the only satisfying answer is a complete session transcript. PowerShell transcript logging via Start-Transcript captures every command you type and every line of output the console displays, writing it all to a text file automatically. No custom logging code required. This post covers the basic usage, path configuration, append mode, auto-starting in your profile, and how organizations enforce transcripts through Group Policy.
Start-Transcript Basic Usage
Start-Transcript begins recording immediately. Without a path argument it saves to your Documents folder with an auto-generated filename including the date and process ID:
Start-Transcript
# Do your work — all commands and output are captured
Get-Service | Where-Object Status -eq Stopped
Restart-Service -Name Spooler
Stop-Transcript
Transcript started, output file is C:\Users\admin\Documents\PowerShell_transcript.SERVER01.abc123.20260504120000.txt
The transcript file is plain UTF-8 text. It opens in any text editor and is easy to search with Select-String.
Save to Custom Path
Specify a path to control where transcripts are stored. Use a timestamp in the filename so multiple transcripts do not overwrite each other:
$logDir = 'C:\Logs\Transcripts'
$logFile = Join-Path $logDir "transcript_$(Get-Date -Format 'yyyyMMdd_HHmmss').txt"
if (-not (Test-Path $logDir)) {
New-Item -Path $logDir -ItemType Directory | Out-Null
}
Start-Transcript -Path $logFile
Write-Host "Session started by $env:USERNAME on $env:COMPUTERNAME"
For scheduled scripts, store transcripts in a shared location like \\server\logs\transcripts\ so operations staff can review them without logging on to the server.
Append vs Overwrite Mode
By default, Start-Transcript overwrites an existing file at the same path. Use -Append to add to an existing file — useful when you want a single daily transcript file with all sessions concatenated:
$dailyLog = "C:\Logs\Transcripts\daily_$(Get-Date -Format 'yyyyMMdd').txt"
Start-Transcript -Path $dailyLog -Append
The -NoClobber switch is an alternative — it prevents overwriting and throws an error if the file exists, which is useful when each session must produce a unique log.
Auto-Start in Profile
Adding transcript startup to your PowerShell profile ensures every interactive session is logged automatically. You never have to remember to start it:
# Add to $PROFILE (e.g., C:\Users\admin\Documents\PowerShell\Microsoft.PowerShell_profile.ps1)
$transcriptDir = 'C:\Logs\Transcripts'
if (-not (Test-Path $transcriptDir)) {
New-Item -Path $transcriptDir -ItemType Directory | Out-Null
}
$transcriptPath = Join-Path $transcriptDir "transcript_${env:USERNAME}_$(Get-Date -Format 'yyyyMMdd_HHmmss').txt"
Start-Transcript -Path $transcriptPath -Append
To prevent double-starts when a script calls Start-Transcript inside an already-transcribing session, wrap with a check:
if (-not $Host.UI.RawUI.BufferSize) { return } # skip in non-interactive hosts
try { Start-Transcript -Path $transcriptPath -Append }
catch { Write-Warning "Transcript already active." }
Stop-Transcript Cleanly
Always call Stop-Transcript at the end of a script rather than relying on session exit to flush the file. In long-running scripts, use try/finally to guarantee it runs even on error:
Start-Transcript -Path 'C:\Logs\nightly-backup.txt'
try {
# ... backup logic ...
}
finally {
Stop-Transcript
}
Transcript stopped, output file is C:\Logs\nightly-backup.txt
Configure via Group Policy
Organizations can enforce transcription for all PowerShell sessions via Group Policy without relying on user profiles. The policy setting lives under Computer Configuration > Administrative Templates > Windows Components > Windows PowerShell > Turn on PowerShell Transcription. You can set the transcript output directory centrally, ensuring logs flow to a monitored share. Verify the current Group Policy transcript settings from PowerShell:
Get-ItemProperty -Path 'HKLM:\SOFTWARE\Policies\Microsoft\Windows\PowerShell\Transcription' -ErrorAction SilentlyContinue
EnableTranscripting : 1
OutputDirectory : \\fileserver\PSTranscripts
EnableInvocationHeader : 1
Common Errors and Fixes
-
Transcript already started — call Stop-Transcript first. You cannot run two simultaneous transcripts in the same session. If your profile auto-starts a transcript and your script also calls
Start-Transcript, the second call throws. Wrap eachStart-Transcriptin atry/catchor check the active transcript with$Host.UI.RawUI.WindowTitlebefore starting. -
Transcript captures display output, not piped data.
Start-Transcriptrecords what appears in the console. Objects sent through the pipeline to a file (Export-Csv,Out-File) do not appear in the transcript. To audit data that goes to files, log the file path and a record count explicitly.
Related Cmdlets / See Also
Wrapping Up
Start-Transcript is the simplest audit logging tool in PowerShell — one line to start, one to stop, and a complete record of everything in between. Add it to your profile for interactive sessions, wrap it in try/finally for scripts, and use Group Policy to enforce it across your environment. Compliance audits become much easier when every session already has a log.


