Tuesday, November 04, 2014

Writing Better PowerShell Scripts with ISESteroids

I’ve been working a lot recently with a nice package called ISESteroids.  As an ISE user, the name got my attention before anything! As the name kind of indicates, the package improves PowerShell’s Integrated Scripting Environment.

So what IS ISESteroids? ISESteroids is a commercial module that you add into the ISE converting the ISE from a good development tool into a much better one. My view is simple: ISESteroids makes me able to write better code, more legible code quickly and easily.

Installing ISESteroids is trivial. Just download the package (it comes as an archive), unblock the archive (after download, right click the archive, select properties then select unblock). Then create an ISESteroids folder under your modules folder, and copy the contents of the archive there.  It should look something like this:


Once the module is in place, you just need to add a line to your ISE Profile:


The first time you run this cmdlet, you have to accept the license agreement, but after a second or two, you can start to experience the added value ISESteroids gives you.

But what is that, I hear you say? There were several things I noticed after first installing ISESteroids. The first of which is that the whole UI changes. The top part of the ISE has the original tool bar expanded and with a second pull down tool bar with more tools. Plus the tool bar at the bottom of the ISE window has been enhanced and now includes a community information feed. This bottom tool bar also has a REALLY nice feature I’ve always wanted – the ability to just take the last command typed at the console and put it into the edit tab. 

Here’s a before and after look (without, then with ISE Steroids installed and running)




The community feed at the bottom is a very nice touch, although all the new tools was surprising (in a nice way). After using it a bit, on a  system without ISESteroids, the ISE felt somewhat more primitive (not unlike using PowerShell V2’s ISE today!).

All those extra tools and a lot of the features in ISESteroids are focused on helping you to write better PowerShell code and streamlining that process as much as you can. In short: good practice built in, and more, more, more automation of the code development process.

Once I started writing scripts with ISESteroids enabled  I saw some changes in the ISE’s Edit pane. Some language elements were marked with a ‘squiggle’ underneath. And the edit pane itself has been reformatted with some new elements. Here’s an example of a very simple script


Just above the number 1 and 2 are two things ISESteroids ‘complains’ about. The first thing is that I used an alias (LS) instead of the full cmdlet name (Get-ChildItem); the second thing is that I am using a string but it is delimited with a double quote, not a single quote. Single quotes, unless you are including variable expansion, are less performant. The third cool thing shown here is that ISESteroids keeps track of functions and shows you how often they are referenced. You can see here the FOO function was referenced just once just once. The final thing to notice is the new search bar – just type a function name, and PowerShell, jumps to that function definition in the code. Great for when you need to update a function definition you call a dozen times in your script!

ISESteroids also makes it easy to get rid of those squiggles. To fix the two issues above, you just hover over the bottom bar in the ISE windows and ISESteroids pops up messages like:



This makes it really simple to fix issues like this. I would have liked to have been able to just right click over the squiggle and select the fix from there – but the bottom of the window works too.

As you delve into using the ISE, just about every menu and tool bar is expanded. To name a few:

  • The File Menu now has an sub menu to open your profile files (you can open both console and ISE profiles).
  • The file Menu also has a Print menu item.
  • The Tools Menu now has a couple of new tools and options.
  • The Add-ons menu has new menu items for moving tool panes around the ISE UI. Useful if you are using some of the tools!

This is just scratching the surface. I’ve got a bit of a coding project coming up and so will be using ISESteroids more heavily and will gladly provide more feedback.

For more information about the product, see the documentation: http://www.powertheshell.com/isesteroids2/documentation/.

One final thing – ISESteroids is not a free product. Single use is €99 although there are volume discounts. BUT because the author is such a fan of the community, he has created what they call their ‘Helping Hands Programme’ – in effect they offer free NFR (not for resale) personal ISESteroids 2.0 Enterprise license in exchange for 3-5 hours of your work, helping them to  make ISESteroids better known, and better documented. A very generous offer!

In summary, ISESteroids is a tool that adds value to the PowerShell ISE and helps you to write  better scripts. If you are writing scripts and other PowerShell related artifacts as a key part of your job then this product is certainly worth the money.

Technorati Tags: ,,

No comments: