Has there been updates to transcription support in a PS 4 Windows Update? Behaviour has changed...

I utilise PowerShell transcription support heavily in my PS scripts. Essentially I utilise transcription as a replacement to having a logging framework - all logging is performed via Write-Host, Write-Verbose and Write-Debug calls, and then logged to file via a call to Start-Transcript at the start of script execution.
Transcription support in PS versions prior to 5 is limited in that it is hard coded in the Start-Transcript and Stop-Transcript commands to throw an exception if the host is not an instance of Microsoft.PowerShell.ConsoleHost. Also, to make it even more difficult, Stop-Transcript throws an error when there is no active transcript; but there is no way to detect if there is. Therefore, I use reflection to get the ConsoleHost.IsTranscribing internal property value to determine whether to call Stop-Transcript at script completion. This logic has worked fine for PS versions 2, 3 and 4. However, more recently I believe a Windows Update patch has changed the way the transcription works. It appears that PS 4 now supports transcription functionality that I thought was PS 5 (CTP) specific - nested transcription sessions (i.e. you can now continually call Start-Transcript and it will create more sessions, rather than throw an error when there is an active session).  Also, the internals of how transcription is managed must have changed because the IsTranscribing property no longer returns the correct value. I am unsure if there is now a "supported" way of checking for this rather than hacking into the internals of the host. This change results in my script creating multiple transcription sessions as it does not know there is already transcription started.

Does anyone know if there has been any updates in PS 4 for the transcription functionality? Or any other details regarding this?

Cheers

April 21st, 2015 7:18am

Hi Bardo,

I tested on powershell 4.0 and powershell 5.0 and found that we can run the "Start-Transcript" and "Stop-Transcript" multiple times without error in powershell 5.0 but not in powershell 4.0:

If this behavior has prevented the script from running, please use try and catch in the script:

try
{
Start-Transcript -Path c:\anna\power1.log}

catch [system.InvalidOperationException]
{
Write-Host "$_.Exception.Message"}

If there is anything else regarding this issue, please feel free to post back.

If you have any feedback on our support, please click here.

Best Regards,

Anna Wang

TechNet Community Support


Free Windows Admin Tool Kit Click here and download it now
April 22nd, 2015 2:58am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics