考慮這個簡單的代碼:錯誤行爲不停止腳本
Read-Host $path
try {
Get-ChildItem $Path -ErrorAction Continue
}
Catch {
Write-Error "Path does not exist: $path" -ErrorAction Stop
Throw
}
Write-Output "Testing"
爲什麼是「測試」如果指定了無效的路徑將被打印到的殼呢?
腳本不停止在catch塊中。我究竟做錯了什麼?