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
Run Code Online (Sandbox Code Playgroud)
代码说明了一切.
Kei*_*ill 12
在ErrorAction
无处不在的参数可被用于沉默使用参数值的非终止错误SilentlyContinue
,它可用于非终止错误转换为使用参数值终止错误Stop
.但它无法帮助您忽略终止错误,在这种情况下,Stop-Transcript会引发终止错误.如果你想忽略,请使用try/catch,例如:
try { Stop-Transcript } catch {}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
7477 次 |
最近记录: |