Setting Up VSCode for PowerShell in 3 easy step

Recently I have switched from PowerShell ISE to VSCode for script development. I was very comfortable with PowerShell ISE except it’s “intellisense” feature which used to hang my system a lot. Switching to VSCode certainly improved my development experience and gave me a better tool for debugging and testing my Powershell scripts.

VSCode is an open-source source code editor which supports multiple programming languages with the help of VSCode extensions.

Installing and setting up VSCode for PowerShell

  1. Install VSCode
    VSCode is available for Windows, Linux and Mac devices. You can install VSCode from https://code.visualstudio.com/Download
  2.  Install PowerShell extension for VSCode
    • Go to Extension
    • Search for ‘Powershell’
    • Select and install ‘Powershell’ extension
    • Reload
  3. Change your default language mode to PowerShell, Once your PowerShell extension is installed you will see that intellisense in VSCode does not provide suggestions like it does for PowerShell ISE, That is because you have not set up your working environment to PowerShell. To change your working environment to PowerShell do follow below steps-
    • In VSCode, hit ctrl + shift + p 
    • Type “Change Language Mode”
    • and, Select Powershell

With the above steps intellisense will work in the current script file but it will not work in a new script file,

  • To make PowerShell as your default language mode do follow below steps.
    • Got to Settings
    • Search for ‘defaultlan’ and you will find below key 
      "files.defaultLanguage": ""
    •  Set this key to ‘Powershell’ and hit ctrl+s,
      "files.defaultLanguage": "powershell"

That’s all you need to do in order to set up VSCode for PowerShell.

Thanks,

Leave a Reply