Behind the PowerShell Pipeline logo

Behind the PowerShell Pipeline

Subscribe
Archives
April 5, 2022

Richer Logging for PowerShell

Over the last several articles, I’ve demonstrated the importance of thinking about objects when creating PowerShell scripts. Once you get your head around the “objects in the pipeline” paradigm, you’ll begin to look at everything that way, which is not necessarily a bad thing. One area which you might not initially consider is logging. By this, I mean you’ve included a logging mechanism into your PowerShell script or function. But if you approach logging from an object perspective, I think you’ll find it much more rewarding.

Why Are You Logging?

Before we dive too deep, let’s consider your rationale for logging. The approach I want to demonstrate requires more work, so you need to be sure it is warranted. I always ask, “Who is going to look at the log and why are they looking?” If the log only exists as a record of activity that will only be reviewed in the event of a problem, or audit, traditional text-based logging may suffice.

Want to read the full issue?
GitHub Bluesky LinkedIn About Jeff
Powered by Buttondown, the easiest way to start and grow your newsletter.