相关疑难解决方法(0)

如何在第一个错误上停止PowerShell脚本?

我希望我的PowerShell脚本在我运行的任何命令失败时停止(例如set -e在bash中).我正在使用Powershell命令(New-Object System.Net.WebClient)和程序(.\setup.exe).

windows powershell

226
推荐指数
8
解决办法
13万
查看次数

为什么在指定-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
Run Code Online (Sandbox Code Playgroud)

代码说明了一切.

powershell

7
推荐指数
1
解决办法
7477
查看次数

标签 统计

powershell ×2

windows ×1