gpt4 book ai didi

powershell - 为什么指定 -ErrorAction SilentlyContinue 时仍然显示错误?

转载 作者:行者123 更新时间:2023-12-04 10:27:42 24 4
gpt4 key购买 nike

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 ubiquitous 参数可用于使用参数值 SilentlyContinue 消除非终止错误。它可用于使用参数值 Stop 将非终止错误转换为终止错误。 .但是,它无法帮助您忽略终止错误,在这种情况下,Stop-Transcript 会引发终止错误。如果您想忽略,请使用 try/catch 例如:

try { Stop-Transcript } catch {}

关于powershell - 为什么指定 -ErrorAction SilentlyContinue 时仍然显示错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11198023/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com