Welcome to our PowerShell blog
PowerShell has grown over the years and become invaluable in the world of SQL Server and automation.
However, it has a quirky syntax and I tend to remember SQL better than anything else, therefore this is my blog to document what I learn as I go...
PowerShell Core ISE (Visual Studio Code)Now there’s a clue in the title on this one. There is no ISE for PowerShell Core. This is because the ISE was a Windows thing and the whole point of Core is that it’s Cross Platform and therefore they haven’t tried to build in a specific ISE that will work for all OS variants.
However, there’s always an alternative and we have one in the form of Visual Studio Code, our friendly cross platform multi-language supporting application.
Visual Studio Code is a standalone application for Source Code Editing and which works cross platform whether that be Linux, Windows, or macOS.
Read More >>
Installing PowerShell Core on WindowsIf you’re thinking of dipping your toe into PowerShell Core to see what it’s about, how it works, and what it does (it’s basically the same as PowerShell 5.1 except cross-platform as discussed in my previous post), then you need to install PowerShell Core.
Luckily it’s a standalone install and will NOT replace PowerShell 5.1 on your desktop or server, running happily side by side. Therefore it’s the perfect way to get started with it and make sure it’s compatible with your needs and scripts before making the full leap.
Read More >>
PowerShell Core - What is it and WhyI’ve been asked this a lot by people recently and I can understand the confusion because it seems that Core is everywhere and yet casual programmers and developers (who, as a SQL guy, are those I tend to deal with) seem unsure what it is and why it exists, yet are being told that they should be using it. Hence I thought I’d just put a quick note in the PowerShell blog about Core even though it’s not a PowerShell exclusive thing, it’s everywhere now, but this is the blog in which it fits best.
So what is Core? Do we need it? Should we all be using it?
Read More >>
When you start testing and writing code in PowerShell, one of the most useful things you can do is to return data to the console in order to see what’s happening, what you’ve done etc and keep track of your code as it runs.
PowerShell provides this in a very simple way and, unlike ECHO in DOS, PowerShell provides us with some formatting too, which can make your code look nice and friendly to both testers and developers.
So, without further ado, let’s get straight to it…
Read More >>
PowerShell vs PowerShell ISEPowerShell has provided us with 2 methods of interaction; a basic console, and the ISE (Integrated Scripting Environment). Personally, I rarely use PowerShell in the console only form, preferring to use the ISE at all times.
With that in mind, I’m going to show them both, but I will focus on the ISE in terms of how I set it up for my coding (you may prefer a different look, but this will let you see how I do it and therefore adapt it to your own preferences).
So, first things first, here’s what I see when I open the Start menu and look in the Windows PowerShell folder:
Read More >>
A VERY Brief History of PowerShellAs 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.
Read More >>
PowerShell was something I didn't really give much consideration to when it first arrived on the scene. It seemed a little bit of overkill compared to existing tools and required a whole new language and way of thinking (pipes versus processes).
For this reason I now have to apologise to PowerShell and point out that I vastly underestimated it as a technology and now I find myself more and more frequently turning to it when I need to get jobs done.
Therefore I figured it needed its own blog.
Within my career as a SQL Server Database Administrator and Developer I've come to rely on automations which SQL Server simply won't allow (well, it will but we all know we shouldn't really have xp_cmdShell turned on).
PowerShell has become my go to tool for automation in respect to so many things... file moves, test harnesses, backups, restores... the list is endless.
And, as with other technologies that aren't SQL Server, I've found myself time and again searching Google for the answers to something I already knew but couldn't remember. And hence I thought I would start a blog in order to document all my PowerShell scripts and some of the techniques I've been using and continue to learn.
Hopefully my ramblings will help other people as well as I add to this in the future.
Read More >>