Microsoft is no longer actively developing the PowerShell Integrated Scripting Environment (ISE). In this tutorial, you'll quickly get up to speed with using Visual Studio Code in many of the same ways you used the ISE.

Timothy Warner

Timothy Warner is a Microsoft Cloud and Datacenter Management Most Valuable Professional (MVP) who is based in Nashville, TN. Check out his Azure and Windows Server video training at Pluralsight, and feel free to reach out to Tim via Twitter.

Latest posts by Timothy Warner (see all)

You may have heard the news that Microsoft is no longer actively developing the PowerShell Integrated Scripting Environment (ISE). This means we Windows systems administrators need a new PowerShell code editor, and for most people, that road leads to the free, cross-platform, open-source Visual Studio Code (VSCode). Yes, "open source" means you can actually contribute to the VSCode code base if you are so inclined.

Today I'm going to teach you to configure VSCode so it behaves largely like the ISE. Honestly, I've found after much resistance that VSCode offers much more customizability (and a better debugger) than the ISE, so I'm happy I finally made the switch.

Install VSCode ^

Go ahead and install the latest VSCode release in any way you're most comfortable with. I suggest you also install Git so you can take advantage of VSCode's built-in Git version control support.

Note: For production environments, I suggest you use stable releases and not the Insiders edition. As it is, the VSCode development team commits stable releases at least twice a month, so you can expect frequent changes and fast bug fixes. Also, you can now install the software without administrative elevation.

Another tip I have for you is to include VSCode to your system's PATH environment variable. This will allow you to launch VSCode by typing Code from the Run dialog box or console prompt.

Include VSCode in your PATH environment variable

Include VSCode in your PATH environment variable

After installation, open the Run dialog box and type code script.ps1. You should observe that Visual Studio opens and creates a new file named script.ps1. At this point, Visual Studio code doesn't have PowerShell intelligence. However, we are going to fix that problem right now.

Install key extensions ^

Click the Extensions icon in the VSCode Activity Bar and type powershell to search the Visual Studio Marketplace. The Activity Bar and the various Side Bar panes are reminiscent of the ISE Add-ons pane.

Select Microsoft's PowerShell extension and then click Install. This extension unlocks PowerShell language support in VSCode, including IntelliSense code completion and a rich debugger. Click Reload to refresh your VSCode session after extension installation.

You will find that VSCode extensions update themselves periodically and that most extension authors work on a DevOps continuous integration software development lifecycle. This is twenty-first century IT after all!

Install the PowerShell VSCode extension

Install the PowerShell VSCode extension

We now have the PowerShell integrated console and full PowerShell support. Go ahead and type some PowerShell code in your script.ps1 file and test it out! By the way, save your script.ps1 test file to disk so we can continue using it throughout this tutorial. Let me walk you through the following annotated screenshot:

PowerShell support in VSCode

PowerShell support in VSCode

  1. A: Use the Tab and arrow keys to navigate IntelliSense
  2. B: Press F8 to run the current code line in the integrated Terminal; select Terminal > Run Active File to run the entire script file
  3. C: Access PowerShell extension options
  4. D: Change the PowerShell engine VSCode uses (yes, this works with PowerShell Core!)

Configure PowerShell settings ^

The Command Palette is the primary navigational/configuration tool in VSCode. Select View > Command Palette or press Ctrl+Shift+P, type configure, arrow down to Configure 'PowerShell' language based settings, and press Enter. As I mentioned previously, you can also click the PowerShell status bar entry to bring up the PowerShell extension options.

Note: The status bar displays the language VSCode identifies in your source code. For PowerShell script and module files, the PowerShell extension should display accordingly.

VSCode has a new user interface for navigating settings. As you can see in the following screenshot, PowerShell-specific editor settings are under Extension > PowerShell Config..., and you can find general editor settings under Commonly used.

Configuring VSCode settings

Configuring VSCode settings

We don't have the space to describe every setting, but I will link you to the VSCode settings reference and share some of my preferred editor/PowerShell settings:

 

If you want to work with the raw settings.json user settings file, open the Command Palette and type Preferences: Open Settings (JSON).

NOTE: All your VSCode settings files are stored in the path %UserProfile%\AppData\Roaming\Code\User.

Change the theme and add icons ^

Microsoft packages the ISE color theme with the PowerShell extension. In the Command Palette, type theme to reach Preferences: Color Theme and then select PowerShell ISE from the list. Arrow up and down through the list of installed themes to test them out; press Enter to commit your change. Use the Extensions sidebar to search for more light and dark themes at your leisure.

PowerShell ISE color theme

I also suggest you install an icon pack to make your files look more meaningful. This step is always optional and perhaps a bit less important now that the ISE theme includes some basic icons. Three popular third-party icon packs are:

  1. vscode-icons
  2. VSCode Great Icons
  3. Material Icon Theme

Below you can see the difference between the default VSCode icon view (left) and the Material Icon Theme view (right).

VSCode custom file icons

VSCode custom file icons

By the way, until you get the hang of the Command Palette, try the gear icon in the lower left corner of the interface. You can get to the icon option here too.

VSCode settings menu

VSCode settings menu

Install PowerShell snippets ^

Pre-built code snippets were one of my favorite PowerShell ISE features. Here's how you can add some nifty PowerShell code starters to VSCode:

  1. Copy the contents of Keith Hill's PowerShell snippets file from his GitHub repository.
  2. In the VSCode Command Palette, type snippet, then Preferences: Configure User Snippets, and then PowerShell.
  3. Paste Keith's snippets over the boilerplate content in the json config file.

As you can see in the next screenshot, AutoComplete and IntelliSense will show you snippet triggers as you type. Alternatively, you can use the Command Palette and type insert snippet.

Using snippets in VSCode

Using snippets in VSCode

Next steps ^

I hope you feel a bit more comfortable using Visual Studio Code. As I stated earlier, I resisted moving away from the ISE because it's been such a faithful tool to me over the years. However, the excellent, helpful community surrounding VSCode helped me to overcome my learning curve and enjoy using the tool to create and maintain my PowerShell code.

Let me leave you with some additional tutorial and reference links for your studying pleasure:

Join the 4sysops PowerShell group!

12+

Users who have LIKED this post:

  • avatar
  • avatar
  • avatar
  • avatar
Share
14 Comments
  1. Alan 11 months ago

    Great article, thank you. Looks like I may be switching as well.

    I had to click on RAW in Keith Hill's GitHub repository or it wouldn't copy properly.

    0

  2. Allan 11 months ago

    Thanks for the article. I have been looking for something like it.

    Allan

     

    0

  3. John G Hohengarten 11 months ago

    Thank you for doing an article like this.

    However, it does not address the primary reason why I have not switched from ISE to VS Code: the ISE Command add-on (View | Show Commands Add-on).

    I rely heavily on the ISE Command Add-on to help me search and filter commands from modules (either searching all modules or selecting individual modules from the dropdown, then searching).

    Are you aware of any efforts to get this functionality similar to ISE's Command Add-on into VS Code?

    1+

    • Author
      Timothy Warner 11 months ago

      Hi John. It's important to remember that VSCode tries hard not to be a GUI tool. Thus, you may want to get familiar with PowerShell commands like:

      Get-Command -Module <module-name>

      Get-Command -Verb Get -Noun AzureRMCompute*

      That said, check the VSCode extension gallery to see if someone else developed a tool to address your use case. Thanks for reading! -Tim

      4+

  4. David Figueroa 11 months ago

    Has anyone found a good (in depth) article on debugging PowerShell in VSCode?  I find myself constantly writing in VSCode, and debugging in ISE w/ISESteroids.. (hopefully this isn't hijacking this article/thread 🙂

    David F.

    9+

    Users who have LIKED this comment:

    • avatar
    • avatar
  5. Mauro 11 months ago

    Thanks, i would like to start using vscode but lack of time/will stick me to ISE, this is just what i wanted

    0

  6. Luc Fullenwarth 10 months ago

    Hi Timothy,

    Thanks for you post.

    On my side I have another reason to not switch completely to VSCode: the lack of PSRemoting tabs functionality.

    With ISE :

    • creating a PSRemoting tabs is easy (CTRL + SHIFT + R)
    • each remoting tab has the name of the remote server
      (in VSCode your have to rename them manually)
    • each remoting tab can be linked to one or more scripting tab dedicated to this particular PSSession
      (in VSCode you have only one "PowerShell Integrate" terminal which is linked to all the scripting tabs)

    There is a VSCode extension named Terminal Tabs, but it's just a look like, good for demos or labs. In fact it's not doing the job of ISE remoting tabs at all.

    That's why I keep ISE for my SysAdmin work with multitasking, interactive sessions or short one-shot scripts while using VSCode for when I want to focus on developing modules or permanent scripts.

    5+

    Users who have LIKED this comment:

    • avatar
    • avatar
  7. Daniel Westerdale 6 months ago

    Hi

    Good post.  I think the PowerShell 1.11.0:  or the (beta) PowerShell Preview 2.0.0 (ms-vscode.powershell-previewPreview) also support the snippets now. 

    Out of interest,  I wonder if there is any resources covering some the settings mentioned
       "files.autoSave": "afterDelay",
        "powershell.enableProfileLoading": true,
        "powershell.integratedConsole.focusConsoleOnExecute": true,
        "powershell.integratedConsole.showOnStartup": false,
     

    0

    • Luc Fullenwarth 6 months ago

      @daniel

      There are so many options available in VSCode...
      Thanks for highlighting those ones!
      I will try them right now.

      0

  8. PaulB 6 months ago

    For years now I have been using ISESteroids by Tobias Weltner which takes the ISE to another level. I hope that some of his work can be migrated across to VS Code. Until then I'm sticking with the ISE. Sometimes progress leads to unacceptable compromises and the benefits of using all the features available in one OS are missed in making it cross platform

    2+

    Users who have LIKED this comment:

    • avatar
    • Daniel Westerdale 6 months ago

      I having also being using Tobias's excellent ISESteroids for client work for a few years now so I understand your reluctance.  Indeed the debugger is much more responsive than VSCode.  That said, the writing is on the wall for both ISE and ISE Steroids so I am making the jump now.

      1+

      Users who have LIKED this comment:

      • avatar
  9. ian hayse 3 months ago

    Is it possible to automatically sort variables by name? 

    0

  10. cogmios 6 days ago

    What is the difference between pressing CTRL-F5 (DEBUG > run without debugging ) and clicking Terminal > Run Active File ?

    0

Leave a reply

Your email address will not be published. Required fields are marked *

*

© 4sysops 2006 - 2019

CONTACT US

Please ask IT administration questions in the forums. Any other messages are welcome.

Sending

Log in with your credentials

or    

Forgot your details?

Create Account