1
问题:PowerShell脚本停止,因为这应该由try块使用$ ErrorActionPreference时被捕获的异常的
例子:
$ErrorActionPreference = 'Stop'
try {
ThisCommandWillThrowAnException
} catch {
Write-Error 'Caught an Exception'
}
# this line is not executed.
Write-Output 'Continuing execution'
也可参阅http://stackoverflow.com/questions/9294949/when-should-i-use-write-error-vs-throw安迪·阿里斯门迪的回答 – Vlad