Scripting SQL Server Installation

Scripting SQL Server Installation

This is where I show that I’m really not a DBA.  I’m an Accidental DBA at best, and a nuisance at worst.  SQL Server already has the capability to be installed via command line parameters or a configuration file.  If I setup the machine the same way every single time, this would be fine, but since I need to change the placement of certain file types, I need to have the ability to change on the fly.

Let’s start with the configuration file.  This is the INI file that is created when you run the SQL Server installation wizard.

This one has already been tweaked for my current build from my previous scripts, but suppose that I wanted to make changes.  It would be pretty easy with the Get-Content and Out-File functions if I wanted to just do simple line substitution.  However, I remembered seeing something in the past on the Scripting Guys Blog about working with INI files and thinking of them as hashtables.  So I went in search and found two functions: Get-IniContent and Out-IniFile.

Here’s how I script its use in the lab.

Let’s say that I want to use the C:\Data location for some files instead of the place configured in the INI file.

So what’s that do to the file?  Here’s what I get (omitting the comments):

So, we’ve got the SQL Server INI File ready, but how do we use it?  Thankfully, Microsoft documented that very well.

All I need is a few parameters and the path to the executable.

Pretty cool, right?  That’s one of the best things about PowerShell.  It’s about sharing.  I didn’t have to write these two functions.  Someone has already done that and shared that information.

Ramble on friends and enjoy the holidays!

1 thought on “Scripting SQL Server Installation

Leave a Comment