Wednesday, July 23, 2008

PowerShell problems with transcript

I really like Start\Stop-Transcript functionality from PowerShell...

However I already encountered few problems:


1.) Transcript doesn't save output from exe files

2.) Log file is not creating new lines (one long line instead)

3.) If script fails, Stop-Transcript is not automatically executed


Transcript doesn't save output from exe files

Yes, that's right. If you run following script:

Start-Transcript c:\temp\testscript.log

You see different output in log file than on screen. Workaround is pretty simple, but functional:

Start-Transcript c:\temp\testscript.log
IpConfig | Out-Host

You pipe output from executable to cmdlet and it is automatically saved to your transcript log file.

Log file is not creating new lines

I experienced this few times and not sure why it happened. If you will run into this problem, you can use my workaround:

Instead of

Write-Host -ForegroundColor $Color -Object "Test"


"Test" | Write-Host -ForegroundColor $Color

Stop-Transcript is not executed

It is not really problem, however you shouldn't forget about it. Easiest way is to include Stop-Transcript in your trap statement:

Trap {Continue} Stop-Transcript


Have you experienced any other problems with transcript?

No comments: