I am running a powershell script from a batch file:
try {
Start-Transcript -path ("C:\PS\Logs\XXXX_Session_QA_" + (Get-Date).tostring("yyyyMMdd-hhmmss-tt") + ".txt")
<Rest of the Code>
}
catch {
stop-transcript
}
Every time I run the script, I see the error
Error: Transcription has not been started. Use the start-transcript command to start transcription.
I have gone through some or most of the previous posts and the code should work but it isn't triggering at all. The initial log file isn't being created either. Any idea why this could be happening or any help here?
try{}around all of your code. Limittry{} catch{}to specific commands and put handling in thecatch{}block for just that command. Otherwise you can't tell which part of your code is failing and triggering thecatch{}logic. - Charlie Joynt