Skip to content
Archive of posts filed under the Scripts category.

Aggregation In PowerShell (and another pointless function)

I’ve been doing a lot of thinking about “idiomatic PowerShell” since my last post and my thinking led me to an idea that I haven’t actually used, but seems like the kind of thing that people would do in PowerShell. If I were writing a script that needed to get a “bunch of things” from [...]

PowerShell’s Problem with Return

I think that PowerShell is a fairly readable language, once you’re used to its unique features. Naming functions (cmdlets) with an embedded hyphen, using -eq instead of the equals sign (and similarly for other operators) and not using commas to delimit parameters in a function call (but using them in a method call) are all [...]

Verifying Automation

If you’re anything like me, you’ve been bitten by the PowerShell bug and are using it among other automation sources to make you life in IT much more enjoyable. If this is not the case…you need to get started!  There’s no time like the present, and a PowerShell New Year’s resolution should be something to [...]

PowerShell and MongoDB

I recently saw this link on using NoSQL with Windows.  Now, I’m a SQL Server DBA, so I haven’t really had any reason to use NoSQL.  I was curious about how easy it was going to be to set up and if I could get it working with PowerShell. I selected MongoDB from the list [...]

Checking a Field for NULL in PowerShell

It’s been a long time (over 2 months) since I last posted.  I’ll try to get back into a rhythm of posting at least weekly.  Anyway, this is something that occurred to me at work when writing a script. I usually avoid nullable columns, but sometimes date fields make sense to be null (rather than [...]

The PowerShell Bug That Wasn’t, and More Package Management

Have you ever tracked down a bug, been confident that you had found the root of your problems, only to realize shortly afterwords that you missed it completely? What I posted yesterday as a bug in PowerShell (having to do with recursive functions, dot-sourcing, and parameters) seemed during my debugging session to clearly be a [...]

Package Management and a PowerShell Bug

UPDATE: I have worked out how the behavior described at the end of this post is not a bug, but in fact just PowerShell doing what it’s told. Don’t have time to explain right now, but I’ll write something up later today. I also worked out how to “fix” the behavior. For a long time [...]

SQL PowerShell Extensions (SQLPSX) 2.0 Released

The first module-based release of the SQL PowerShell Extensions (SQLPSX) was released recently on CodePlex.  It features very handy wrappers for most of the SMO objects used to manipulate SQL Server metadata, SSIS packages, Replication, and (new in the 2.0 release) an ADO.NET module which I wrote based on the code in this post.  There’s [...]

Get-EventLog and Get-WMIObject

Recently, we had an occasion to write a process to read event logs on several sql servers to try to determine login times for different sql and Windows logins.  Since we have begun using PowerShell v2.0, and since get-eventlog now has a -computername parameter, it seemed like an obvious solution. The event message we were [...]

An Overlooked Parameter

This isn’t so much a post as an extended pingback.  This Post by Jeffrey Snover on the PowerShell Team Blog explains how to use the -expandproperty parameter of the select-object cmdlet. I had never noticed that parameter and was also annoyed by writing this all the time: get-something | foreach {$_.SomeProperty} It was an idiom [...]