为什么指定 -ErrorAction SilentlyContinue 时仍然显示错误? [英] Why does an error still show when I specify -ErrorAction SilentlyContinue?
本文介绍了为什么指定 -ErrorAction SilentlyContinue 时仍然显示错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
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
代码说明了一切.
推荐答案
ErrorAction
无处不在的参数可用于使用参数值 SilentlyContinue
和它可用于使用参数值 Stop
将非终止错误转换为终止错误.但是,它无法帮助您忽略终止错误,在这种情况下,Stop-Transcript 会引发终止错误.如果您想忽略,请使用 try/catch 例如:
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 {}
这篇关于为什么指定 -ErrorAction SilentlyContinue 时仍然显示错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文