Gavin Whitson, 6/l3/2024
I created this module because when refactoring an existing base of PowerShell scripts, modules that logged to a database felt like they had added complexity from having to interact with SQL as well. Our scripts used the .NET SQLClient module and so I began to make wrapper functions that convert the interactions with these functions feel more native to PowerShell.
To layout the basic interactions between the database and my module, I first figured out what all I wanted it to be able to do. This is fully intended to be a lightweight module to wrap the functionality of a more complete batch of commands, and NOT a reimplementation of the commands themselves. Therefore, I decided that any functionality should be restricted to an already created database. What I wanted to allow came down to creating tables, and reading and writing to them.
This started with creating functions that manipulate existing PowerShell types to be more in line with SQL and what is expected to be used in the queries. DateTimes are converted to a string representing the data through SQL syntax, Strings are formatted to have the be able to be added into a query, etc, etc. This just gives us a basic amount of pre-processing available that makes sure that we are not battling with types being invalid for the database.
With these conversions setup, we can start building our functions that add functionality to our module. These functions are essentially just string builders that use the resulting string in the calls to the SQLClient module while providing the user with an abstracted interface for it.
Truthfully, I do not intend to continue working on this. There are a couple of changes that I may make if additional functionality is needed, however my mentatlity towards modules like this has since changed. I no longer feel like a module like this is anything other than a crutch that stops people from growing with technology that is slightly foreign to them. Throughout the course of writing this module, it became apparent to be that it is pointless if the overall SQLClient module is used properly.