PowerShell and Visio Part 1 – Introduction

I’ve been playing around with Visio and PowerShell for quite a while now and the experience is something of a mixed bag.  My first thought was to use PowerShell to build integration diagrams, reading server names, domains, VLANs, and datacenter locations from a database, and adding color-coded connections to show the network connection requirements (e.g. …

Continue reading ‘PowerShell and Visio Part 1 – Introduction’ »

PowerShell Code Smells: Boolean Parameters

This is a real quick one. In PowerShell, the “native” way to express a two-state variable is with Switch parameters. For instance: When calling Test-Thing, you can either supply -Recurse or leave it off. It’s a flag. This is PowerShell 101. Programmers coming from other languages are used to Boolean variables. Sometimes, one slips through …

Continue reading ‘PowerShell Code Smells: Boolean Parameters’ »

7 Ingredients of Professional PowerShell Code

If you’ve been using PowerShell for any amount of time you’ve probably written a lot of code. Here are some guidelines I’ve come up with for what I consider “Professional” code. I should note that I’m assuming some basic things like correct verb-noun naming, commented code, reasonable variable names, etc. Also, the code should work! …

Continue reading ‘7 Ingredients of Professional PowerShell Code’ »

Invoke-SQLCmd considered harmful

I mentioned here that Invoke-SQLCmd (included in the SQLPS module for SQL Server) was susceptible to SQL-Injection attacks, but I haven’t demonstrated that or ever seen anyone show it. To do so, I’ll start with code out of the help for Invoke-SQLCmd.  Here’s the code (taken from here) Notice that the parameters are encoded in a …

Continue reading ‘Invoke-SQLCmd considered harmful’ »