Published: Dec 05, 2021
As a note, this will not be a large discussion around why PowerShell exists and whether it should or shouldn’t exist, how performant it may or may not be etc. I’m literally just going to explain why I use it, why I think it’s worth investing some time in, briefly why it exists, what it can do, and how and why you, likely as a SQL Server professional, should consider reading some of these blog posts.
So firstly, most SQL Server professionals who have been around a good few years (I’ve been around more than I care to admit) have, at some point or another, had to fall into the clutches of MS-DOS. This was, for me at least, always a painful process.
I don’t know about anyone else but I always found myself doing mundane tasks in DOS either line by line manually or through a crude batch file but, more than anything, as a SQL guy I spent my time pulling data into SQL Server using xp_cmdShell and then manipulating it before getting SQL to ask DOS to do further tasks. This was the only way I could get flexibility into my accessing the operating system.
I can only imagine many other professionals (especially those in Infrastructure who try to automate file system commands, deployments, registry access etc) have had similar DOS based traumas in their lives.
Then PowerShell appeared.
PowerShell is basically an upgraded and updated DOS on steroids. It’s like going into hospital for a cracked rib and coming out like Robocop. (Obscure and random reference, I’m just in one of those moods, sorry).
PowerShell is a scripting language which interacts with the core of Windows (and now other operating systems too), allowing access to areas previously hidden away. It can do everything DOS could (manipulate files and folders etc) but also interact with the Registry, communicate with the .net framework, COM, WMI, Exchange, Sharepoint, Hyper-V, SQL, Excel, websites etc, it can understand, read, and write CSVs, JSON, XML etc.
It can do this via an old console style tool which reminds me very much of DOS, but also through an ISE (Integrated Scripting Environment) which is a GUI allowing “proper” coding of scripts to take place.
To be honest I was very sceptical at first and it took me a while to even consider using PowerShell but, now that I have, I genuinely love it and hence this series of blogs as I progress.
Hopefully you’ll realise how useful and powerful it is as much as I have and also that these blogs help take away some of the pain of learning it through a series of trial and error and Google searches.