Search This Blog

Monday, 16 May 2016

ISESteroids - Exhaling from the complication of PowerShell version control

ISESteroids

How I found...

Backstory - Tl;Dr - I stumbled into coding

For the purpose of this article, I would describe myself as a power user with added Google, not a programmer, technician or any other title that would insinuate I have had any form of structured training in creating programmatic solutions. I'm just a guy who grew up in PCs; playing with them, fixing them, sleeping on them. I am by no means methodical in my programming and scripting. I approach new languages by having a goal in mind and acquire only the necessary information to achieve this, which gives some bare understanding but always a poor foundation that eventually becomes more established as the use of the language becomes more required. It's a bad way of learning for various reasons, but I find it allows you to easily change your understanding of the language in an instant. So I can barely read ASM, barely code in C, code console applications in C++ and can program various windows applications in C#. There's some batch scripting in there, VBscript and now PowerShell.

The main thing I learned from this is that most goals are achiveable by using any of the languages, but the caveats of each method and language make them particularly well suited to one type of task or another. You can have developers toss around jargon about who's language is better but languages aren't created for fun (well, yes but no). Lots of people have spent a long time making a defined language, getting it established and giving it relevance. They're created with intent and that makes them tuned. Knowing which one suits your purpose is half the battle.

The Project - Help People

I help people with PCs. Possibly out of a sense of duty, probably out of ego, definitely with one intent; Make the user more comfortable. Not just content, but with a sense of security. This is why I back up Windows installations and advise personal data be stored on other medium than your operating system disk. Still, this does not prevent people laying waste to their OS and possibly the disk. Although there are a few recovery techniques available to recover even the severest of data loss, there is no guarantee that any method will work and usually results in a full reinstallation of the OS and associated applications anyway. The faster you can make this happen, the generally more comfortable people are.

Whenever I find myself repeating anything in computing, there's probably a way to automate it, and in this case, the method is clearly scripting. Creating a program to do the install of multiple applications and system setting configurations can be done, but due to the simplicity of editing, the ease of flexibility and the general ability to handle various types of installers with their own quirks, scripts work for me.

PowerShell, how your versions aggrivate me so

Batch was the boy back in the day when I was a boy for handling Windows OS and even today, due to the sheer simplicity, lots of IT professionals rely on batch scripts, usually and ironically to launch other types of scripts (I use a batch to start a PowerShell script). The the age old and still thriving start of my scripting life has evolved through various new implementations for greater system control (VBScript) and updated with a greatly expanded set of system interfaces (PowerShell). I love the greater flexibility in controlling the all aspects of the operating system and the language is strangely asthetically pleasing, but now I find myself knee deep in the "pipeline" getting pounded by unknown object types. Microsoft have provided a good integrated scripting environment (ISE) for PowerShell, but jeez, it's bare.

 

Steroids?? Ok...

This is the 4th iteration of PowerShell I'm using  and it still feels a bit lacklustre. The bare essentials are there for a scripting environment; coloured highlighting and intellisense (auto-complete :P) but still, in terms of error checking and debugging, you're usually on your own. This can leave you resorting to trial and error of scripts and entering commands every time you need to pull up help or running tandem with a browser. Some of these are more serious than others but the straw that made me seek a better alternative was version control. How could I tell if my scripts would run on a PC with only PowerShell v2, or if other apps are called in? The time and effort it would take to research the compatibility of every command in my scripts and modules could take me a lifetime, or at least feel like it, so I looked for something that could provide the most needed aspect... Luckily, it came with much more. Enter ISESteroids.


Getting Started With ISESteroids

Installing

This was slick. If you have PowerShell v5, you can just open the normal ISE and type some commands (available on their downloads page). As I'm poorer, I got the download package.

It was a case of unzip, click install.bat, start the ISE and type "Start-Steroids"... And thats it...

Can't fault it for simplicity and there are instructions on how to make it load with the ISE, but that choice is up to you. I like having the option to step up to for full editing and bare ISE for quick typos (What? They happen...).

The UI

It gave me a wonderfully warm reminder of the time as it began initialising.
 

Then the UI with an array of new buttons.


Jumping straight in

Immeditately, it felt like what I was hoping for. A familiar interface with more control. So I loaded a script and opened the new "Context Sensitive Help Add-On" which I was excited to read about on their reviews. This wonderful little thing grabs relevant help to whatever is selected in the scripting window.
 

The squiggly line shows me where an error exists or simply better writing could be used. That was particularly useful in scripts where I'd used the "Where" alias everywhere, wheras a more compatible "Where-Object" would be better. So when I selected and hovered over the squiggly line under a string I'd written in this script, the side bar displayed information about what I selected and the popup told me that using single quotes would be better practice. Very cool for my learning curve. Even better, if you follow the line with the correction to the left edge, there's a lightbulb icon that, when clicked, will correct all this type of correction in the entire script.

 

So with automatic script fixes and real-time context sensitive help, I can see the value in this. After making the correction, the help panel updated.

 

Solving the problem

The main reason I'd got this was to see if something very important worked. This was version checking. In my version, this was in the "Compatibility" section of the main menu strip.

 

It was only then that I also stumbled across the "Create Compatibility Report" function which does exactly as it says, giving a list of all the dependancies your script has to outside objects such as other modules, executables and more. The only thing that came back on mine was references to my other modules.

 

Summary

There's no doubt that this software has some real power under the hood, adding so much that I haven't mentioned and resolving a lot of the pet hates I had when working with PowerShell. If you're working with PowerShell intensively, either as a hobbyist or a professional, I would advise at least taking the free 10-day trial just to see what it can do for you. ISESteroids has helped me correct and refine much of my poor scripting, it's gonna be hard to go back to anything else.

Nice work, problem solved.

No comments: