Structured Error Handling
Over the last few articles, I've been teaching you about PowerShell's error system and how to handle errors properly. The worst thing you can do is pretend errors don't exist by turning the error pipeline off.
$ErrorActionPreference = "SilentlyContinue"
As a general rule, you also don't want to simply "eat" the error.
Try {
Get-Service $svc -ErrorAction Stop
}
Catch {
}
Want to read the full issue?