Crafting Better PowerShell Code with ISESteroids

One of the best enhancements I’ve used for PowerShell is called ISESteroids. Much like the name implies, it wraps a great number of features and functionality around the standard PowerShell ISE. I’d suggest downloading a trial to see if it blows your mind. Note that I had some issues with my PSModulePath variable on one of my devices. If you’re not able to kick off the Start-Steroids cmdlet in the PowerShell ISE, you may be in the same boat. ISESteroids also has a pretty detailed README file with some common troubleshooting scenarios (such as protected ZIP downloads and firewalls eating the psexec app).

When you’re done with the trial, there are a number of price points based on your use case – companies, individuals, startups, education, Microsoft MVPs, home use. This post is just me sharing my joy with ISESteroids with the world – I’m a happy paying customer of the Enterprise edition!

Handy Features

There’s a number of reasons that I really dig ISESteroids. Chief among them is the ability to use AutoRefactor. This tool will parse through your PowerShell code and clean it up based on a long list of rules. Each rule can be individually toggled on and off, you can run them individually, or you can let AutoRefactor go to town on your code.

refactor

This seems like a spectacular tool for new PowerShell users. It helps them see how to write and format clean code. It won’t, however, create comments within the code – something I suggest forming a habit around. 🙂

Writing PowerShell functions can be pretty annoying because of all the “dot sourcing” to load a script and then test it out. ISESteroids removes much of this pain with the Test Arguments feature. If you right click on the Run Script play button, there are choices to define arguments or even disable dot sourcing.  These arguments persist during the session for testing purposes, but are not associated with the script in any other way. It avoids having to type in a bunch of information each time a script is tested – a real time and error saving feature.

test-script-args

Other neat options appear if you right click on the Run in Console button. You can run using different console types and users to help scrub your personal profile shenanigans away from the test.

run-test-in-console

As you’re coding, it’s also possible to validate that your cmdlet choices will be compatible with the intended audience using the CompatAware feature. I usually just leave this set to PowerShell version 4, but if you needed to write legacy code for PowerShell version 2, you can change the level and ISESteroids will mark any code that doesn’t work in that PowerShell version in the editor.

compataware

There’s a number of other features that I find handy, but the ones listed above are top of mind as being favorites. I’ve been using ISESteroids for long enough now that I’m pretty used to all the snazzy things it does, so it’s sometimes hard to remember what the legacy ISE looks like. 😉