Visual Studio Code: PowerShell Profile

1uqcgx

Intro

Microsoft has released a terrific open source, multi-platform code editor called Visual Studio Code. If you want to get started with VS Code, I would recommend watching the videos provided here and then watch this excellent video about replacing PowerShell ISE with Visual Studio Code by Mike Robbins.

What about the PowerShell profile?

While Visual Studio Code can use PowerShell as its terminal, it does not use any previously setup PowerShell profile. In order to create a VS Code PowerShell profile (or VSCPP for short), select the Terminal (make sure it says PowerShell Integrated in the drop down on the right) and type $profile.

VSCode1

In order to create this file, you can type PS>notepad $profile in the terminal. This will open notepad and let you create the file. You can add whatever settings you prefer to in PowerShell. Once you save the profile, hit F1 or Ctrl+Shift+P to bring up the Command Palette and type Reload Window.

VSCode2

When the reload completes, create a new PowerShell file in VS Code and you should see the Terminal switch to PowerShell Integrated and load your newly created VSCPP (this assumes you have installed the PowerShell extension into VS Code).

VSCode3

NOTE: The PowerShell version that is installed as an extension into VS Code, has its own version.

VSCode4

If you have modules, scripts, or functions that have a dependency on a certain version of PowerShell, you will have to change, comment, or remove the dependency in order to use them in Visual Studio Code.

Happy Scripting!
Alain

5 thoughts on “Visual Studio Code: PowerShell Profile”

  1. Is there a way to just use VSCode to point at the existing powershell profile that you’ve already created? It seems like with how much VS Code has available for customization – that we should be able to do this.

    1. Since it is a different name you cannot as far as I know. I would just copy the contents of your regular PowerShell profile into your one for VSCode. You may want to add a time/date check to the VSCode profile so you know when to resync them.

  2. Excellent blog post as I didn’t know how to edit the profile. Working with the PowerShell preview team, I will pass on their suggestions: replace notepad and edit the profile in VSCode Open-EditorFile $profile or New-EditorFile $profile which creates the file if it doesn’t exist. Thanks again for posting

Leave a Reply to Alain Cancel reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.