7
PS C:\Users\ad_ctjares> Stop-Transcript -ErrorAction silentlycontinue
Transcription has not been started. Use the start-transcript command to start transcription.
Stop-Transcript : An error occurred stopping transcription: The console host is not currently transcribing.
At line:1 char:16
+ Stop-Transcript <<<<  -ErrorAction silentlycontinue
    + CategoryInfo          : InvalidOperation: (:) [Stop-Transcript], PSInvalidOperationException
    + FullyQualifiedErrorId : InvalidOperation,Microsoft.PowerShell.Commands.StopTranscriptCommand

The code says it all.

Caleb Jares
  • 6,163
  • 6
  • 56
  • 83
  • Don't know, but there's a bug filed on Connect about it, together with a workaround: http://connect.microsoft.com/PowerShell/feedback/details/549321/start-stop-transcript-ignores-erroraction – Dogmang Jun 25 '12 at 22:16
  • Thanks - that led me to here: http://stackoverflow.com/questions/6307127/hiding-errors-when-using-get-adgroup, where I found out I need to use `try { } catch { }` because `-ErrorAction` doesn't affect Terminating Errors – Caleb Jares Jun 25 '12 at 22:27

2 Answers2

13

The ErrorAction ubiquitous parameter can be used to silence non-terminating errors using the parameter value SilentlyContinue and it can be used to convert non-terminating errors to terminating errors using the parameter value Stop. However it can't help you ignore terminating errors and in this case Stop-Transcript is throwing a terminating error. If you want to ignore, use a try/catch e.g.:

try { Stop-Transcript } catch {}
Keith Hill
  • 194,368
  • 42
  • 353
  • 369
  • Any full list about terminating errors ? http://stackoverflow.com/questions/15545429/erroractionpreference-and-erroraction-silentlycontinue-for-get-pssessionconfigur – Kiquenet Mar 21 '13 at 11:06
3

You can use Trap {Continue} Stop-Transcript instead to avoid any errors.

de.coding.myth
  • 125
  • 1
  • 9