Repository navigation
Open
Labels
Committee-ReviewedPS-Committee has reviewed this and made a decisionPS-Committee has reviewed this and made a decisionIssue-Enhancementthe issue is more of a feature request than a bugthe issue is more of a feature request than a bugWG-Cmdletsgeneral cmdlet issuesgeneral cmdlet issues
Description
Start/Stop-Transcript does not always capture everything written to the console.
I created a github repo with code, repro steps and more context: https://github.com/zammitt/PowerShellTranscriptIssue
Steps to reproduce
In a script file (.ps1)
- Start-Transcript
- Run a Cmdlet that outputs data with WriteObject
- Stop-Transcript
- Observe that the output was not written to the transcript
Here is a script to repro:
Install-Module TranscriptIssue
Import-Module TranscriptIssue
Start-Transcript -Path transcript.txt -UseMinimalHeader
Write-Output "Hello from Write-Output"
Write-Host "Hello from Write-Host"
Test-TranscriptIssue
Write-Output "Goodbye from Write-Output"
Write-Host "Goodbye from Write-Host"
Stop-Transcript
# Write out the transcript to the console
cat ./transcript.txt
The code for Test-TranscriptIssue can be found here: https://github.com/zammitt/PowerShellTranscriptIssue/blob/master/TestIssueOnPowerShellCore/Test-TranscriptIssue.cs
Expected behavior
The contents of the transcript match what was written to the console while the transcript was active.
Transcript started, output file is transcript.txt
Hello from Write-Output
Hello from Write-Host
Goodbye from Write-Host
TestProperty
------------
TestValue
Goodbye from Write-Output
Transcript stopped, output file is D:\code\PowerShellTranscriptIssue\TestIssueOnPowerShellCore\bin\Debug\netcoreapp3.0\transcript.txt
**********************
PowerShell transcript start
Start time: 20191105180138
**********************
Hello from Write-Output
Hello from Write-Host
Goodbye from Write-Host
TestProperty
------------
TestValue
Goodbye from Write-Output
**********************
PowerShell transcript end
End time: 20191105180138
**********************
Actual behavior
The transcript is missing data that was written to the console while the transcript was active.
Transcript started, output file is transcript.txt
Hello from Write-Output
Hello from Write-Host
Goodbye from Write-Host
TestProperty
------------
TestValue
Goodbye from Write-Output
Transcript stopped, output file is D:\code\PowerShellTranscriptIssue\TestIssueOnPowerShellCore\bin\Debug\netcoreapp3.0\transcript.txt
**********************
PowerShell transcript start
Start time: 20191105180138
**********************
Transcript started, output file is transcript.txt
Hello from Write-Output
Hello from Write-Host
Goodbye from Write-Host
**********************
PowerShell transcript end
End time: 20191105180138
**********************
Environment data
Name Value
---- -----
PSVersion 6.2.3
PSEdition Core
GitCommitId 6.2.3
OS Microsoft Windows 10.0.17134
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Reacted by Michael Klement, NateScarlet, sirisian, Wei Shi, Alexandr Miloslavskiy, steve green, Marcos Soutullo Rodriguez, DennisL68, 정승원(SeungWon Jeong)/OnC, Cary Symes and 8 more
Reacted by Mr Beedell, Roke Julian Lockhart
Metadata
Metadata
Assignees
Labels
Committee-ReviewedPS-Committee has reviewed this and made a decisionPS-Committee has reviewed this and made a decisionIssue-Enhancementthe issue is more of a feature request than a bugthe issue is more of a feature request than a bugWG-Cmdletsgeneral cmdlet issuesgeneral cmdlet issues
Activity
JamesWTruher commentedon Nov 6, 2019
TLDR:
I’m not sure this is a bug, per se, but a subtle interaction between the script and how transcription works with our pipelines. I will agree that it is in no way intuitive.
One of the things that happen when you emit objects is that the formatting of those objects gets handled by out-default, but after the script has completed and since transcription has stopped, that output doesn’t get transcribed. Strings are handled differently, they’re sometimes short-circuited through formatting (but sometimes not). The combination of write-host (which makes an immediate write), write-object (which may get short-circuited through formatting), and output of a makes this pretty hard to reason about what’s going to happen. However, there may be a way that you may want to try (See “A POSSIBLE WAY” below).
Even more details:
Here are a couple of variations on the theme:
Variation 1 – your scenario, with the output of a structured object at the end of all of the other operations.
This one is really confusing, but explainable (but perhaps not satisfying). ‘Write-Host 4’ is visible before
get-locationbecause Write-Host is hot-rodded directly into the host and emitted (there’s code in transcription which essentially tees the output to the transcript file and the console). Then we have the regular output ofget-locationandwrite-output 5sent as output of the script.Since transcription is turned off before the script exits, it’s not rendered in the transcript, because the objects were sent to the next consumer in the pipeline (in this case, it’s out-default which is what the engine does automatically). The tricky bit is that strings are also somewhat hot-rodded in our formatting, so the first
write-output 2gets emitted and captured by the transcript, but the insertion of theget-locationobject causes it to be pushed into the stack of things that need actual formatting, which sets a bit of state for any remaining objects which may need formatting (which is why the secondwrite-output 5doesn’t get transcripted.Variation 2 – move the object emission to the beginning
We can see that the
write-hosthappen before anything, and then the objects start to come out. The string output essentially forces the object to be rendered to the screen, but you’ll notice that the transcript contains only the output of Write-Host. That’s because those were piped to the formatting after the script turned off transcription.Variation 3 – object emission at the end:
We can see that everything but the object is now in the transcript
Here’s the execution flow
And the content of the transcript
A Possible Way
Lastly, here’s a slight variation on the original, but now everything will be in the transcript. I’ve taken the code of interest and am calling the formatter forcefully via out-default. You’ll notice that the last Write-Host call is still out of order, that’s because of the short-circuiting of write-host which is a direct call into the host and does not go into the output stream.
Here’s the execution, followed by the transcript
he852100 commentedon Nov 7, 2019
I suggest adding a new option. Allows it to output color documents
zammitt commentedon Nov 8, 2019
James Truher (@JamesWTruher) Thank you for the detailed reply. Out-Default works great! I ended up using the -Transcript flag so that the objects are still passed forward on the pipeline.
he852100 I'll second this. Color in transcripts would be awesome.
vexx32 commentedon Nov 8, 2019
My one question to that is always going to be -- how? PS works with text files, not formatted documents. The next step up would perhaps be Markdown, which would be messier to read in the console, and still doesn't natively support color formatting. That should probably be a whole other issue discussion, though. 😉
SteveL-MSFT commentedon Jan 8, 2020
@PowerShell/powershell-committee reviewed this, we believe a complete solution for transcription (like the unix
scriptcommand) would love to see the community build a new cmdlet (published to PSGallery) that uses ptty or on Windows grabbing the screen buffer, but the ask is out of scope for the current transcription framework.Cloudmersive commentedon Mar 7, 2020
Dear Microsoft - when are you going to fix this? Steve Lee (@SteveL-MSFT) this is critical functionality - how is it "out of scope"? It is critically important that bedrock Microsoft capabilities actually solve problems at scale and this is a huge gap
mklement0 commentedon Mar 7, 2020
To complete the picture of the current problems and limitations:
Interactive prompts are never transcribed - unlike with the Unix
scriptutility, you neither see the prompt string nor what the user typed.Inconsistent Start-Transcript behavior with respect to the error and information streams #4645 describes duplicated output in transcripts and situationally changed behavior when transcript ion is used.
As for the
Out-Defaultworkaround for the issue at hand:Given that we shouldn't promote use of
Out-Defaultin user code,Out-Hostis the better choice, but it is still a flawed workaround:On Unix-like platforms, use of the
scriptutility already is an option to bypass all these issues (albeit not from within a script), while additionally providing:However, the
PSReadLinemodule doesn't play nice with the latter inRead-Hostcalls; e.g. (on Linux):If you type
abcwhen prompted, the transcript won't contain just stringabc, but the equivalent following, which makes the terminal go haywire when youcatthe resulting file; note how each letter typed caused the inclusion of VT sequences and reprinting of all letters typed so far:sba923 commentedon Dec 4, 2020
Just discovered that
Start-Transcripttypically captures little to no output fromROBOCOPY.PSTranscriptAndRobocopy.zip
Would there be a workaround?
30 remaining items
arakielG commentedon Mar 22, 2025
Just to add my voice to this still being an issue. I have an install script that runs a bunch of winget commands. Start-Transcript captures the first half dozen or so and then after that the only thing getting transcribed is the Write-Hosts I have between them all
`Installing EdgeView2Runtime...
Found an existing package already installed. Trying to upgrade the installed package...
No available upgrade found.
No newer package versions are available from the configured sources.
Installing Google Drive...
Found an existing package already installed. Trying to upgrade the installed package...
No available upgrade found.
No newer package versions are available from the configured sources.
Installing Google Chrome...
Found an existing package already installed. Trying to upgrade the installed package...
No available upgrade found.
No newer package versions are available from the configured sources.
Installing BitWarden...
Found an existing package already installed. Trying to upgrade the installed package...
No available upgrade found.
No newer package versions are available from the configured sources.
Installing Git...
Found an existing package already installed. Trying to upgrade the installed package...
No available upgrade found.
No newer package versions are available from the configured sources.
Installing GitLFS...
Found an existing package already installed. Trying to upgrade the installed package...
No available upgrade found.
No newer package versions are available from the configured sources.
Installing GitHub Desktop...
Found an existing package already installed. Trying to upgrade the installed package...
No available upgrade found.
No newer package versions are available from the configured sources.
Installing UnityHub...
Installing JetBrains Rider...
Installing VSCodium...
Installing Windows Terminal...
Installing Powershell...
Installing WSL...
Installing Ubuntu...
` ... etc
A9G-Data-Droid commentedon Jun 2, 2025
The response from Microsoft here has been really surprising. At the very least,
Stop-Transcriptshould call for a flush and wait for flush of anything at the point when stop is called. As for it's inability to capture all output, that is certainly a bug and it's absurd to say it's not. There should be no workaround or call upon the community. This feature doesn't do what it says on the tin. Is it supported or not?sba923 commentedon Jun 12, 2025
IMVHO a broken transcript feature is about as useful as no transcript feature.
So, this must be fixed, or removed/deprecated.
microsoft-github-policy-service commentedon Dec 10, 2025
This issue has not had any activity in 6 months, if there is no further activity in 7 days, the issue will be closed automatically.
Activity in this case refers only to comments on the issue. If the issue is closed and you are the author, you can re-open the issue using the button below. Please add more information to be considered during retriage. If you are not the author but the issue is impacting you after it has been closed, please submit a new issue with updated details and a link to this issue and the original.
jkmartindale commentedon Dec 10, 2025
still a footgun, bot bro
DennisL68 commentedon Dec 10, 2025
Just because no one is working actively on this issue doesn't mean that a solution isn't in high demand.
lonbluster commentedon Dec 31, 2025
broken on Windows 2019, no output generated in transcript file
PSVersion 5.1.17763.8146
microsoft-github-policy-service commentedon Jun 30, 2026
This issue has not had any activity in 6 months, if there is no further activity in 7 days, the issue will be closed automatically.
Activity in this case refers only to comments on the issue. If the issue is closed and you are the author, you can re-open the issue using the button below. Please add more information to be considered during retriage. If you are not the author but the issue is impacting you after it has been closed, please submit a new issue with updated details and a link to this issue and the original.
jkmartindale commentedon Jun 30, 2026
Bump
EclipsedStar0 commentedon Jul 26, 2026
Powershell transcription is completely missing over half the console output of running a python file printing to console... and they are all strings. Which was said to be done correctly. No it ain't. This is broken.