I was surprised that the below checking of a non-existing drive does not transfer control to the Catch area. Why is that?
$DebugPreference = "Continue"
try {
Write-Debug "Before Error"
Get-ChildItem -Path "Q:\" # Q is a non-existing drive.
Write-Debug "After Error"
Write-Debug ("Error in Try block: " + $Error[0])
}
catch {
Write-Debug "Catch"
Write-Debug ("Error in Catch block: " + $_.Exception.Message)
}
-Tom. Microsoft Access MVP