PowerShell Code Smell: Invoke-Expression (and some suggestions)

Code Smells I’ve mentioned code smells in this blog before, but to recap, a code smell is a warning sign that you might be looking at bad code (for some value of bad).  Code smells are more like red flags than errors.  Some classic example of code smells are very long functions, lots of global variables, …

Continue reading ‘PowerShell Code Smell: Invoke-Expression (and some suggestions)’ »

The Two Faces of the ISE Run Button (and a bit of bonus evil)

I love the ISE. I’ve used other “environments”, but always end up using the good old ISE. I do use the awesome ISESteroids module by Tobias Weltner (powertheshell.com), but most of the time you can find me in the unadorned, vanilla ISE. With that bit of disclaimer out of the way, there is something that …

Continue reading ‘The Two Faces of the ISE Run Button (and a bit of bonus evil)’ »

Why Adolib (and POSH_Ado)?

I’ve realized that in my explanations of Adolib and POSH_Ado, I left something important out. Why in the world am I spending all of this time and effort writing database access modules when there are already tools out there (SQLPS, for instance) which work. The simple answer is SQLPS is not good enough for several …

Continue reading ‘Why Adolib (and POSH_Ado)?’ »

Breaking the rules with helper functions

One of my most popular answers on StackOverflow is also one which has a tiny bit of controversy. It involves how to “hide” helper functions in a module in order to keep them from being exported. Export-ModuleMember Details In case you’re unfamiliar with how exporting functions from a module works, here are the basic rules: …

Continue reading ‘Breaking the rules with helper functions’ »

Quick Tip – Avoid abbreviating parameter names

Looking at some of the solutions to the July scripting games problems (here) I noticed that several of them used abbreviations for parameter names.  For instance: I understand that this is a competition of sorts and that part of the challenge is to get a solution with the smallest number of characters, but I realized …

Continue reading ‘Quick Tip – Avoid abbreviating parameter names’ »

PowerShell Best Practices

I’ve seen several posts on PowerShell best practices, and even read Ed Wilson’s book on the subject. There is some commonality in the lists in the obvious places (verb-noun, output objects, format your code nicely), and some disagreement in other areas (code signing, for example). I also see a great amount of variation in use …

Continue reading ‘PowerShell Best Practices’ »