When writing a “get-” function in PowerShell, you often run into the issue of filtering your data. Do you want to include any filtering parameters? Do you want to allow lists of values? Do you want to provide “include” or “exclude” parameters? What about wildcards? I got tired of writing the same kind of code …
Continue reading ‘Flexible Filtering’ »
If you’re like me, you hate to do the same thing over and over. That’s what programming is for, right? To handle automating tedious procedures? Unfortunately, it’s not at all appropriate to run off and build an app every time you need to do the same thing 3 times. If you try that, you’ll have …
Continue reading ‘A Handy Trick I’ve Started to Use a Lot’ »
When preparing a PowerShell training class for a group of DBAs, I realized that there were some parallels between basic SQL and basic PowerShell commands. A (very) basic SQL statement has the form: SELECT <COLUMNS> FROM <TABLE> WHERE <CONDITION> ORDER BY <EXPRESSION> I noticed that a very common idiom for PowerShell pipelines* was: <data source …
Continue reading ‘Is it just me? (Or does PowerShell remind you of SQL?)’ »
We all know that using string concatenation (or substitution) in SQL is a “bad thing”. If you google “SQL Injection”, you’ll find hundreds of pages that tell you not to do things this way and that you need to use parameterized queries. However, I still see a lot of code in PowerShell that does this: …
Continue reading ‘Executing SQL the Right Way in PowerShell’ »
In a recent post , I showed how to get a list of Scheduled Tasks as objects using PowerShell and Import-CSV. In that, I included the following line of code:
In this post, I’ll try to explain why I did that.
Tools I Use (note…these are all free!): PowerGUI Script Editor (I haven’t ever gotten the hang of PowerGUI itself) Powershell Community Extensions 1.2 (PSCX) PowerTab SQL PowerShell Extensions 1.61 (SQLPSX) PrimalForms Community Edition Books: PowerShell In Action by Bruce Payette Professional Windows PowerShell Programming: Snapins, Cmdlets, Hosts and Providers by Arul Kumaravel et. al. Mastering …
Continue reading ‘PowerShell Tools and Books That I Use’ »
There are a few approaches to manipulating scheduled tasks in PowerShell.
* WMI – Useful if you are only going to manipulate them via script. The tasks will not be visible in the control panel applet.
* SCHTASKS.EXE – Works ok, but has a somewhat arcane syntax, and is a text-only tool.
* Task Scheduler API -Best of both worlds, but only on Vista (not XP).
Why am I writing a blog about PowerShell? The answer is simple. I haven’t been as excited about a technology since I first learned SQL. PowerShell allows me to do my job in a much more consistent, flexible, and scalable way.
What is it about PowerShell that has me so fascinated?