Behind the PowerShell Pipeline logo

Behind the PowerShell Pipeline

Subscribe
Archives
March 15, 2022

Logging PowerShell Profiles

Last month we dove into the world of PowerShell profile scripts. These configuration scripts run automatically every time you start a PowerShell session. As long as you aren’t manually starting PowerShell with the -NoProfile parameter. If you are using the profile script hierarchy as I suggested, there is one more element you may want to include, and that is logging.

Windows logs a lot of PowerShell activity, regardless of how it starts. We’ll look at this in a future article. I’m referring to generating a log of profile script activity. I use this, and I thought you might find it helpful. Or, at the very least, you might be able to leverage the concepts.

LogPSStart

The core concept is to write a text message to a log file. I’ll record activity in each profile script to this central log file. I’m not doing anything fancy. Here is the basic PowerShell function I am using.

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