【发布时间】:2014-12-07 13:21:00
【问题描述】:
问题:powershell 脚本因异常而停止,在使用 $ErrorActionPreference 时应由 try 块捕获
例子:
$ErrorActionPreference = 'Stop'
try {
ThisCommandWillThrowAnException
} catch {
Write-Error 'Caught an Exception'
}
# this line is not executed.
Write-Output 'Continuing execution'
【问题讨论】:
标签: powershell