Announcing PowerShell language support for Visual Studio Code and more!

Today I am very happy to announce Developer Preview releases of two new projects that I hope will take your PowerShell development experience to the next level.

Write and debug PowerShell scripts in Visual Studio Code!

The first release is a new extension for Visual Studio Code which provides improved PowerShell language support including IntelliSense, code navigation, real-time script analysis, and local script debugging. Previous releases of Visual Studio Code have provided basic PowerShell syntax highlighting support and code snippets. This summer I started working with a PowerShell team intern, Kayla Davis, to bring PowerShell to parity with the in-box C# and TypeScript support. This new extension takes the feature set much further:

[The following images are animated GIFs, click to play!]

IntelliSense and signature help for parameter sets

Code navigations like “Go to Definition” and “Find References”

…even across dot-sourced files!

Viewing the list of symbols in the current script file or project path

This feature is our first community contribution by PowerShell MVP Keith Hill! I am really excited to be able to ship this extension with a community contribution already in the box.

Real-time script analysis using PowerShell Script Analyzer

Local script debugging

You can even set variables to be watched!

Basic interactive script console

…and this is only the beginning!

In the near future we intend to add even more great features:

Better support for advanced language features like workflows, classes, and DSC configurations

Remote debugging support

Improved interactive console support

Quick fixes for common syntax rules

PowerShell Gallery integration for finding and installing PowerShell modules from within the editor (a contribution by PowerShell MVP Doug Finke)

Support for PowerShell v3 and v4

We would love to hear your feedback about this extension and would love even more to have you contribute to the code! Check out the vscode-powershell GitHub repository for more details.

Installing the extension

To install this extension, make sure you have the latest Visual Studio Code update installed (version 0.10.1, just released today!). You will also need to have PowerShell 5 either by using Windows 10 or by installing Windows Management Framework 5.0 Production Preview. While running Visual Studio Code, open the command palette by pressing Ctrl+Shift+P and then type “Extension” then select “Install Extensions”. Once the extensions list loads, type PowerShell and press Enter. That’s it! Restart Visual Studio Code and open folder containing PowerShell script files to get started.

If you don’t have a folder of PowerShell script files (shame on you!) I’ve included one with the extension and some instructions on features to try out. Open this file path in VS Code and look at the README.md file:

Enabling PowerShell development support in any editor

The second release is a new project called PowerShell Editor Services. This project provides a new common platform for enabling rich PowerShell development support in any editor. It is composed of two parts: a .NET library which provides core PowerShell language intelligence and debugging features and a hostable process with JSON API for integration into editors that are written on a development platform other than .NET. The goal of this project is to enable other code editors like Sublime Text, Atom, Emacs, Vim and others to have the same level of PowerShell development support as Visual Studio Code, customized to the strengths of each editor. All of the features that you see in the Visual Studio Code extension are provided by this project! I’ll be publishing packages to NuGet in the next couple of days so keep an eye out for that.

These APIs should be considered very new, unstable, and likely to change as we learn more about usage scenarios and feature set. We will be working with the PowerShell community to get things stabilized and documented to 1.0 release quality in 2016.

We are actively looking for contributors to this project, especially to help with integrations with the editors that you care about. Please check out the PowerShellEditorServices GitHub repository for more details.

One last thing: Fans of PowerShell ISE, stay tuned for another great announcement next month!

I’m doing a lot of my PowerShell for Microsoft Infrastructure (AD, Exchange etc), Azure and VMware and would like to know if it’s possible to add additional modules into the Intellisense framework? Even things such as the ActiveDirectory module would be handy.

Is this possible? If so, how?

Cheers,
Steve

2 years ago

Guilherme

“In the near future we intend to add even more great features:”

…
* Code beautifier (pretty print)!

Thank you! 😉

2 years ago

jb

Can’t install it.
I updated to .10.11 … & Downloaded files… but where do we put them? Because the install extension can’t find the files.
Thanks,
JB

Chris Smith: I'll be pushing out an update soon which should help with this issue. If you continue seeing the problem after receiving the 0.2.0 update, please file an issue at the GitHub site and I'll help diagnose the problem:

So I have it installed and the extension enabled…..intellisense, though, seems to be taking forever to show up, and then it only shows up a couple times before it quits. Preview product problem or something I can adjust?

Jacqueline P: Right now the PowerShell Tools for Visual Studio extension still has better support for remote debugging and attaching to an existing process which uses the PowerShell runtime. It also has a better interactive console experience. These things will change over time, though, as the Visual Studio extension will start to share the exact same core as the VS Code extension (which will be improved from this sharing of logic). You will ultimately be able to use the same editing behavior in both places.

2 years ago

Bingchong

Great stuff…. 🙂

2 years ago

Jacqueline P

Cool! Will this replace the need for using Visual Studio (which I think is a bit too bloated for just Powershell use)?

In a future release I'll try to find a way to provide a default launch configuration so this is easier to do.

2 years ago

Kirk

Hi,

Trying to run this with Windows 7 and the Windows Management Framework 5.0 Production Preview – I can open a .ps1 file and get syntax highlighting, I don't get full intellisense – seems to work some times, and only for some commands, running in debug mode or running a script shows launch.json not set up correctly – any idea of the value's that need to go in? Below is what I currently have: