Behind the PowerShell Pipeline logo

Behind the PowerShell Pipeline

Subscribe
Archives
July 25, 2023

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?
GitHub Bluesky LinkedIn About Jeff
Powered by Buttondown, the easiest way to start and grow your newsletter.