Is there anything more opinionated than a coder and her tools? Perhaps debates about Star Trek versus Star Wars (Trek is better). With that in mind, let’s talk about tools for writing PowerShell code. I first cut my teeth on PowerGUI and then traded that in for PowerShell ISE once the ISESteroids module went mainstream. Ever since the PowerShell and DevOps Global Summit, however, I’ve been spending more and more of my time with Visual Studio Code (VSCode or @Code). And for good reasons, I think.

Let me start this post by sharing how much I really enjoyed ISESteroids with PowerShell ISE. I supported the author with an enterprise license because the module is just that insanely awesome. However, the PowerShell folks have made it crystal clear that the PowerShell ISE is getting long in the tooth and not going to receive much love. They pointed me to VSCode. After gasping at the download size – I was expecting something along the lines of the previous Visual Studio editors – I realized that the initial release was far too lightweight for my needs and missed out on the features I enjoyed my previous setup. Now days, though, it’s pretty darn fantastic.

Here’s a collection of three features you can find in VSCode that I think are pretty snazzy.

Code Refactoring

One of my favorite features in the ISESteroids module was the ability to easily refactor code to adhere to space, tab, and formatting standards. This included the expansion of aliases, such as gmo turning into Get-Module ; the addition of requires statements for needed version or module dependencies; and the normalization of line endings. Handy stuff.

Visual Studio Code uses the Format Document command. Open the Command Palette (F1 key or Ctrl+Shift+P) and start typing format document to see the command or use the shortcut Shift+Alt+F. This will clean up the code in a similar fashion.

What’s more awesome is that all of the format settings can be easily edited. Just cruise over to File > Preferences > Settings. From there, you can search for settings within the Default Settings JSON and even overwrite any of the settings to your own User or Workspace Settings configuration. For PowerShell specific formatting, enter powershell.codeFormatting into the search box to see the available configuration entries.

This makes the creation, maintenance, and sharing of custom ISE configurations a snap. It’s also something you can version with Git!

Finding (And Fixing) Problems

Intellisense is one of the most delightful features you can find in the PowerShell world. It helps autocomplete variables, cmdlets, and other bits of code. Taking that idea further, the “Problems” menu at the bottom of VSCode is a fairly verbose readout exclaiming anything you’ve done incorrectly within the code. I like the use of colors and a simple, human-readable error message. One click on the Problem will migrate the cursor to the issue painted in a squiggly red line.

In many cases, I can right click the entry to see a suggested fix. It’s certainly easier than trying to remember what the yellow bang, orange cone, and red X mean at the bottom of PowerShell ISE. 🙂

Debug Console

The last major feature that I rely on frequently is the debug console. Giving credit to PowerShell ISE for a moment, the use of ISESteroids made debug and variable exploration a snap. It’s a must-have for anyone writing a module or lengthy scripts, especially when functions are calling one another.

The debug capabilities in VSCode are ridiculously good. Not only does the color coding help figure out where and what is being run, but the breakpoints menu (buttom left) also shows where all the active breakpoints exist in the stack. There’s also a snazzy variable explorer and integrated terminal so that you can view inside the code and even make changes in real time! I’m used to dealing with debuggers that mark all of the code read-only, making this the ultimate feature.

Thoughts

Visual Studio Code is free and available for all major operating systems. It’s lightweight, easy to update, and has a wealth of open source plugins available. There’s native Git integration and a plethora of colorful themes to select from. Hats off to the development team on this slick and fun ISE!

What do you think – is VSCode something you’re looking to use or tried in the past? Have you made it your default ISE or still feel like something else – such as PowerShell ISE or perhaps even PowerGUI – are still the best tools in the business? Let me know in the comments below! 🙂