Skip to main content

Powershell ISE and ISESteroids

Overview

I've been programming for over half my life now in one form or another. Over the years I've dabbled in Visual Basic 6.0, Java, Ruby on Rails, Perl, PHP, and most recently Powershell. I was asked recently if I could help a non-profit with some administrative tasks within their Windows environment. So, I set out to learn some PowerShell.

First Encounter

I first encountered PowerShell a few years back when I helped build a script with a GUI that would allow the admin to easily create and remove distribution groups based on a database of people. That was about 6 years ago and since then I hadn't touched the stuff. At that time Powershell 2.0 had just released if I recall correctly, and there existed very limited resources for learning and fixing code. So, when I picked PowerShell back up a few weeks ago I was very surprised how easy it was to learn again. I wrote a program that would do a significant portion of what we needed in a matter of a few days.

Then, while searching for how to use a feature that I was familiar with from other IDEs, and finding the feature didn't exist in the default Windows PowerShellISE, I came across an addon that honestly blew me away. The addon was called ISESteroids (http://www.powertheshell.com/).

ISESteroids

Overview

I installed ISESteroids on a whim to try to split my code so I could see two sets of code at once. This was such a simple little feature and ISESteroids was overkill - But I installed it anyways. This addon isn't its own ISE, it installs on top of the Windows PowerShell ISE that I was already used to. New buttons and menus suddenly appeared around my script and I'll admit I was a little overwhelmed at first. But, after reading through the menus and clicking buttons to see what they did, I've found a few very useful features that I would like to share. Keep in mind, this is by no means a comprehensive list of features; that would take a book instead of a blog post. Instead, I'm going to detail some of the extra features I have discovered so far that have been very helpful.

ISESteroids
Picture of extra buttons and menu options once ISESteroids is started

PSSharper

As I mentioned before, I am no stranger to programming. I am also very particular about consistency. Many times, I've spent an hour to figure out the proper way to make something work, even though I had already found a solution that would get the job done. But, I don't want to just get the job done! I need it to be done efficiently. I need it to adhere to standards. And, I need it to be scalable and future-proof. I'll admit that I sometimes don't have the luxury to adhere to these principles but I do my best.

So, when the formatting of my code lit up with highlights and green underlines I was thrilled!

PSSharper, as it is called, is a feature bundled inside the ISESteroids addon that analyzes performance issues and generally helps clean up your code. Simple principals of coding in PowerShell like don't use aliases within a written script and avoid positional parameters were being applied in real time to the code I had worked so hard on. In a couple of clicks I had produced a list of issues from the sidebar that not only allowed me to jump to the location of the problem but, often times, would auto fix the issue as well!

Manage Issues

Variables

As I was programming I came across an odd issue. I had created a recursive function that was designed to drill down into XML data and return a hash of data. After some troubleshooting, I found that the variable I was using was getting messed up somewhere along the way. In most programming environments, the variables are wiped between runs but I realized then that PowerShell kept all variables and functions in memory for the session. I began searching for ways to remove the variables. The methods I found were actually very dangerous. Removing all variables (while running as an administrator) could even cause the Windows PowerShell ISE to stop running. This is when I stumbled upon another simple and powerful feature of ISESteroids, the Variable Monitor

Variables
Variable Monitor

Not only does this allow you to view the variables your script produced but that little green button highlighted in the above picture deletes these variables safely. Clicking this button actually cleared up my variable issues and made the function work correctly.

Exporting Modules

Refactoring is an important skill to hone in the world of programming. I found myself in need of creating functions that, once created, would be used throughout my code to perform various tasks. I initially created these functions at the bottom of my code.

This, of course, was a very bad idea. Instead, I needed these functions to be called at the beginning of my script so they could be used throughout. While mousing over one such function, I noticed a little wrench. This wrench had the option to Export function to module.

Exporting Modules
Export Module Option

After completing the simple GUI form my function was converted into a module. I was even able to specify the location so the module would exist within my code environment! Now, I simply import the module at the beginning and all of my functions are available.

Module Export Menu
Module Export Menu

This greatly simplified the process of refactoring functions for me. It also helped modularize the code so that, if anyone else was helping on the project in the future, it wouldn't just be one giant file of code for them to decipher.

Summary

This is only a small glimpse into the plethora of features that ISESteroids has to offer. I've noticed but haven't yet used File Version History, LivePresent, and Auto-Format to name a few. And, there is more to discover as I become familiar with this excelexcellent.

If you are new to PowerShell, like me, or a grizzled veteran, I recommend giving this addon a try.

Comments