Visual Studio Code Powershell

Microsoft has knocked it out of the park with Visual Studio Code. I’ve seen a lot of positive feedback for it, even on one of the forums I read that isn’t related to programming or devs or IT Operations. For my purposes I’ve recently started using it for Powershell. And I wanted to share some of what I’ve found using the Visual Studio Code Powershell extension.

To get started you can download the latest version here.

 

It’s that easy to install

add powershell to visual studio code

As you can see there are a ton of other extensions. Another interesting one is the Stack Overflow Search, allowing you to search Stack Overflow directly from Visual Studio Code.

 

Editing Your Code

Naturally the first thing I did was drop one of the biggest scripts I have into the editor. The extension found some issues with my SCOM Distributed Applications script.

visual studio code powershell problems

It found several variables that I had declared and never get used, oops. It nags for aliases, which is actually fantastic. I’ve seen a broader push lately to stop using aliases. The reason for this being, the next person that comes along to read your code may not be familiar with the aliases you are using. Thanks to it finding these problems, I’ve since fixed them all.

 

If you forget a comma from parameters, it notes it like Powershell ISE does. However, it also turns your file a different color giving you the error count next to the filename.

visual studio code powershell errors

The Intellisense feels faster than Powershell ISE. I have no empirical evidence for this, but I do know sometimes in Powershell ISE I have to stop typing, erase and start typing again to get Intellisense to pop up. So far this hasn’t happened to me in Visual Studio Code.

 

Source Control and Themes

visual studio code powershell source control

Two things Visual Stuio Code has over Powershell ISE is integration into multiple source control providers, in fact you can integrate into multiple at the same time.

And lastly themes, just typing themes into the extensions section brings up a ton of themes you can select.

 

One sad thing is, currently neither the Azure Automation ISE Module or the Service Management Automation ISE Module work in Visual Studio Code. I foresee myself writing the bulk of my automation in VS Code and then transferring over to Powershell ISE to test in Azure Automation or SMA.

All in all I really like the Visual Studio Code Powershell extension, it probably has way more than I need right now, but it is a definite upgrade over Powershell ISE.

Hi, I’m Billy York.  I’m a Cloud and Datacenter Engineer, specializing in monitoring and automation. Here you’ll find posts about System Center Operations Manager, Powershell, Hyper-V, Azure Automation, Azure Log Analytics and other Microsoft related technologies.

1 thought on “Visual Studio Code Powershell

Comments are closed.