问题:powershell 脚本因使用 $ErrorActionPreference 时应该由 try 块捕获的异常而停止
例子:
$ErrorActionPreference = 'Stop'
try {
ThisCommandWillThrowAnException
} catch {
Write-Error 'Caught an Exception'
}
# this line is not executed.
Write-Output 'Continuing execution'
Run Code Online (Sandbox Code Playgroud) powershell ×1