Still using PowerGUI? Get on the Visual Studio train!

Are you still using the old Quest / Dell PowerGUI tool to author your PowerShell scripts and modules? If so, you may want to consider getting off the PowerGUI train, and hopping onto the Visual Studio 2015 or PowerShell Integrated Scripting Editor (ISE) train! By doing so, you will improve your PowerShell script & module authoring experience, and you’ll have a whole host of tools at your fingertips, that will increase your productivity!!

As always, make sure that you’re running the latest version of the Windows Management Framework (WMF) package, to ensure that you’ve got the latest version of PowerShell installed! Also, if you’re not a developer, and lean more towards the IT pro side of things, don’t be intimidated by Visual Studio. It’s a beast, I get that, but learn to tame the beast, and harness its power, and you will certainly become more productive, you will be able to collaborate on projects more effectively as a team, and you will have many more tools available in your toolbox!

Authoring PowerShell in Visual Studio 2015

Visual Studio 2015 RTM’d just recently, back on July 20th, with great fanfare! There are tons of new features, including full support for Microsoft PowerShell MVP Adam Driscoll’s baby known as PoshTools! For any new projects you’re kicking off, or even existing projects you’ve got in-process, make sure you give the PoshTools extension a whirl!

Not too long ago, I made a video on MSDN Channel 9 that talks about the benefits of PoshTools, so start by watching that!

Why You Should Use Visual Studio PoshTools!

Visual Studio 2015 Team Explorer

Visual Studio 2015 Team Explorer

You should definitely use PoshTools for your PowerShell automation projects, most importantly because Visual Studio supports the notion of project files! Project files help you keep track of all the individual script files that make up your overall project! If you already have an existing Visual Studio solution, and need to add deployment or configuration management scripts to your solution, you can simply add a new PowerShell project to the solution!

Visual Studio also makes for a great PowerShell authoring experience, because it includes full support for Intellisense! You also benefit from the incredible Visual Studio support for keyboard shortcuts!! If you’re using source control for your PowerShell projects (which you should be!!), then you automatically get the Team Explorer window, which integrates with services like Visual Studio Online (VSO), GitHub, and others!

By leveraging the Visual Studio framework, you automatically get the ability to rely on other add-ons, such as the Markdown editor included with the Web Essentials VS extension, authored by Mads Kristensen (Microsoft). You can search through the VSIX Gallery for more Visual Studio extensions!

Visual Studio Web Essentials - Markdown

Visual Studio Web Essentials – Markdown (Animated GIF)

Visual Studio PoshTools Limitations

While the overall PowerShell authoring experience in Visual Studio is excellent, thanks to PoshTools, you might run into some challenges!

First of all, the Visual Studio debugger can hang sometimes, for unknown reasons. Secondly, the debugger occasionally loses track of which line a particular piece of code is running on, so it might throw you off. Thankfully, this bug is easily worked around by restarting Visual Studio! Third of all, the PowerShell Interactive Window doesn’t always format objects the way you’d expect, so it’s a bit more complicated to get the desired output, compared to using the PowerShell ISE. This is mainly an issue for interactive work, but any time you’re writing and testing code, there is a combination of automated and interactive work!

Authoring PowerShell in ISE

PowerShell ISE :: DSC Intellisense

PowerShell ISE :: DSC Intellisense

Microsoft has made great strides in the PowerShell Integrated Script Editor (ISE) since its inception in PowerShell version 2.0! Although it could still use quite a bit of work, Intellisense support has been improved dramatically! PowerShell Desired State Configuration (DSC) even supports Intellisense for authoring configuration documents and DSC resource instances inside them.

Why You Should Use ISE!

If you’re running a combination of interactive PowerShell commands, and script authoring — which is pretty typical — the PowerShell ISE will be more forgiving, compared to Visual Studio PoshTools. Objects emitted to the output stream will be formatted correctly, and the debugging experience is a bit more reliable, even though it could still use some work as well.

Syntax highlighting is one of the essential features of any development environment, and the PowerShell ISE has a great set of default colors to differentiate commands from parameters, parameter values, and other syntactical constructs. Both the PowerShell ISE and Visual Studio PoshTools extension win big points in this area!

If you install Jason Shirk’s (Microsoft employee, PowerShell core team) TabExpansion++ module, you can add support for custom “argument completers!” These custom argument completers are really cool, because you can add support for tab-completion of PowerShell cmdlet parameter values, that aren’t even part of your own module!

If you’re authoring Service Management Automation (SMA) or Azure Automation Runbooks, which are simply PowerShell Workflows (as of today), you will benefit from a new ISE add-on developed by the Azure Automation team. This add-on helps you to write and test your Runbooks locally, and then upload them to Azure Automation directly from the ISE, without having to pull up the Microsoft Azure management portal!

Here’s a list of other PowerShell ISE add-ons that you can use to help enhance your productivity!

ISE Limitations

While the ISE has been our friend for the past 6 years or so, it suffers from its own set of problems. It doesn’t provide as robust a framework for extensions as Visual Studio, and it doesn’t have the same level of flexibility for configuring keyboard shortcuts. As a PowerShell script author, you should certainly be accustomed to the productivity benefits that keyboard shortcuts provide! Intellisense performance problems also plague the ISE, as you’ll frequently see Intellisense timeouts occur, with few options to work around them, or better yet, fix them for good.

Because the ISE doesn’t support the notion of project files, it can be very challenging to keep track of which files make up your project, and keep track of which files are currently open. It simply doesn’t do as good of a job at window management as Visual Studio does.

When it comes to essential text editing functions, like search & replace, Visual Studio’s mechanism is significantly more robust, allowing you to search through your entire project, or all open files, at once.

Conclusion

If you’re using old or basic tools, like Notepad, Sublime Text, or Quest (now Dell) PowerGUI, I would strongly encourage you to check out the Visual Studio PoshTools Extension and the PowerShell Integrated Scripting Editor (ISE)!! You’ll benefit from syntax highlighting, auto-completion, code formatting, Intellisense, extensions, and much more!

Feel free to follow me on Twitter, watch my MSDN Channel 9 videos, and add me on Skype @ pcgeek86 or Skype for Business (S4B) at trevor@trevorsullivan.net!

  • Pingback: Dew Drop – August 4, 2015 (#2067) | Morning Dew()

  • Pingback: Trevor Sullivan's Tech RoomMicrosoft Visual Studio as a Python IDE - Trevor Sullivan's Tech Room()

  • Pingback: Create a Visual Studio Project for your PowerShell Scripts - Trevor Sullivan's Tech Room()

  • Jon

    I recently installed VS 2015 and the PowerShell tools. Aside from the Git support and being able to easily create projects or modules, when it came to the actual coding, I thought it wasn’t quite as nice as PowerGUI. For example, PowerGUI gives better descriptive information in the yellow popup box when using intellesense, etc.

  • Matt

    The main reason I can’t stand to develop in the ISE is that when I try to copy a variable, its leaves the $ behind. Seriously…. why?

  • Donoho

    PowerGUI was like the Notepad++ of IDEs (before abandoned by it’s current owner). Although ISE has some nice features, it still “feels” bloated in comparison despite not having the magical Variables Tab.
    As far as Visual Studio integration goes, it’s great if/when I’m already working in VS. However, if I just want to open/check/do a quick edit, it’s massive overkill. It’s like driving an hour+ away to a discount-warehouse for a single roll of paper towels.

  • wpx7

    PowerGUI is still a fave of mine because it still feels more polished, smarter and easy to use without being an overkill, compared to the ISE and PoshTools.
    It’d be great if a core extension could be put out to be host-able in VS (like Posh), while still being able to run standalone like ISE and incorporate the goodies from PowerGUI.
    I’m probably asking too much 😉 🙂 Happy Coding!

  • Pingback: Getting Started with PowerShell Tools for Visual Studio - Please Release Me()

  • OpenMike

    Trevor you seem to always shed wherever I’m struggling with a particular question or dilemma. You have a keen sense for the challenges specific to IT pros. The thoroughness of this article and the words of encouragement have convinced me to stay the course with VS15, as the learning curve does seem daunting.

  • OpenMike

    Also, I’ve been hearing about Visual Studio Code. Just another stripped down IDE with pros and cons? Or does it have some of the same sensibility advantages of VS15?

    • Hey Mike, sorry for the late response. I’m not sure how I missed this. Visual Studio Code is an excellent tool that’s lighter weight, relative to Visual Studio 2015, and offers quite a bit of extensibility. One of the things I like about VSCode is the ability to open any folder as a “project.” The main thing I love about VSCode though, is its awesome Command Palette. Give it a try!

  • Jason Milczek

    Trevor, how would you compare VS 2015 with Powershell extension to Powershell Studio by Sapien?

    • Good question, Jason. I don’t have a license for PowerShell Studio, and haven’t tested it out. Do you think there are any missing features from PowerShell ISE, Visual Studio, or Visual Studio Code?

  • Abdul Rehman

    Hello

    I could not solve the exception
    The term ‘Get-Function’ is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

    can you please guide me what I am missing

  • Sunish Surendran
  • Mohamed Rizan

    I’ve been using PowerGUI for a while now. I like the debugging feature. It saves me the time to troubleshoot the script. I really like PowerGUI over ISE

  • Pingback: Why I use Visual Studio Code to write PowerShell - Trevor Sullivan()

  • KERR

    I like the Powershell ISE. It’s pretty good for a built in tool – and that’s the best part, you don’t need to download or install any extra software. Intellisense is cool, but also the Snippets feature is great for getting up and running with loops or Try/Catch/Finally and other templates. The ISE also has themes support, and supports addons.

  • Richard

    Can the tools be persuaded to run powershell version 2 (ie. Powershell -version 2.0) on a system with version 3 installed? I am still working with SharePoint 2010 whose powershell extensions are not supported in V3

  • Anon Wibble

    Why would anyone use visual studio? It’s the world’s most buggy editor, with some buggy intellisense. Just why.

  • disqus_7IJCku831D

    Where is the exe creation support for ISE or VS?