PowerShell is a scripting language and task automation framework created by Microsoft allowing .NET developers to leverage the command line they know and the .NET APIs they already use. It is a very flexible and expressive procedural language with pipeline and first-class objects support for script blocks. All of these things and more allow PowerShell to be incredibly powerful, flexible, and a great target for managing systems, scripting tasks, or creating a DSL.
What is Missing
One of the most often asked questions I have seen when using PowerShell is why MS didn’t integrate it into Visual Studio. I do not have an answer, but one can venture a guess. Using Visual Studio costs a lot of money and developers are not the primary target audience. System administrators and IT staff are the most likely users of the system and one would not want to pay for them to have Visual Studio. So MS creates PowerShell ISE; a free, lightweight, script editor which comes installed on servers and Windows 7 machines. The general user story is complete, but it will cost a lot of money to create an integration for Visual Studio, and the resources that can create the integration are limited and could be used to create products that make money. Given this, I would guess that we will never see MS created PowerShell integration in Visual Studio.
How We Got Here
When I first started working with PowerShell, I discovered the console, and it was ok. Then I discovered ISE, and it was better; however, I am not a system administrator or infrastructure technology specialist. I don’t want to hop between different applications when I am writing my code and scripts.
A while passed and I started getting into Chewie, psake, and NuGet scripts, but I was continually frustrated that my workflow changed when I wanted to edit my scripts, or I could edit them in Visual Studio which is pretty much the same as working with notepad when editing a PowerShell script. It would be nice to have my scripts editable in VS and grouped together and editable as a project.
Out of my frustration, I set out to see if I could improve this experience; given that I can’t quite seem to stop giving away software I write, I quietly started working on an OSS project to solve this problem. A few months went by and something started to form that satisfied my workflow. About a month ago, I released PowerStudio on the Visual Studio Gallery and can be installed through Visual Studio’s Extension Manager. It currently supports
- Code coloring matching your Visual Studio settings
- Fonts and zoom matching Visual Studio
- Built-in and declared variable auto-completion IntelliSense
- Function auto-completion IntelliSense
- Error detection for tokens and expressions
- Tooltips for error information
- Code folding
- Brace matching
- Project and file templates
- Variable tab sizes
- Visual Studio project type
- Selected word highlighting
You can browse and download the source code and feature requests on GitHub. My next goal is to get script execution and debugging working natively from within Visual Studio. It has been a great learning experience on how to extend VS2010. If you have any suggestions, please go to the GitHub page and let me know.