Share via


Visual Studio Code: Getting Started with PowerShell


This TechNet Wiki "Getting Started" aims to provide simple basic instructional information, links to material related to Visual Studio Code to get anyone started. Feel free to improve this article relevant to the Visual Studio Code and adjust the table of contents where appropriate.

1. Introduction

Visual Studio Code was announced with a preview released on 29th April 2015 by Microsoft at 2015 Build conference. On 18th November 2015, Visual Studio Code was released under the OpenSource MIT License and its source code released to GitHub with Extension support announced. On 14th April 2016, Visual Studio Code graduated public preview stage and was released to public.

Visual Studio Code is a source code editor that supports a number of programming languages such as C, C++, C#, CSS, F#, HTML, Less, Java, JavaScript, JSON, Markdown, PHP, PowerShell, Python, Rust, Sass, Swift, Text, TypeScript, Visual Basic, XML, XSL and YAML. For users, Visual Studio Code has installable for multiple operating system platforms such as Windows, Debian, Ubuntu, Redhat, Fedora, CentOS, OS X Yosemite and El Capitan. It is also able to integrate with Git for GitHub.

 

↑ Return to Top


 

2. Getting Started with Visual Studio Code

In this section, we will get started by downloading and installing Visual Studio Code just to get you started on working with Visual Studio Code.

 

↑ Return to Top


 

2.1. Requirements

Since Visual Studio Code is available in multiple variety of Operating System platform, we high recommend you to find the correct package for your platform from the download site below:

 

↑ Return to Top


 

2.2. Download Visual Studio Code using PowerShell

In this section, we will demonstrate how to download Visual Studio Code using PowerShell on Windows.

# Download Visual Studio Code from

#  https://code.visualstudio.com/#alt-downloads

Invoke-WebRequest `

    -Uri 'https://go.microsoft.com/fwlink/?LinkID=623230' `

    -OutFile 'C:\Temp\VSCodeSetup-stable.exe' ;

 

↑ Return to Top


 

2.3. Install Visual Studio Code silently using PowerShell

In this section, we will demonstrate how to install Visual Studio Code silently using PowerShell on Windows. You can also refer to the setup resource for Windows operating system below:

# Begin SILENT installation of

#  Visual Studio Code

Start-Process `

    -FilePath 'C:\Temp\VSCodeSetup-stable.exe' `

    -ArgumentList '/SILENT /LOG="C:\Temp\VSCodeSetup.log"' ;

 

 

↑ Return to Top


 

2.4. Install Visual Studio Code on Non-Windows Operating System

In this section, we will provide the setup resources for Non-Windows operating system below:

Once Visual Studio Code has been installed, you can launch Visual Studio Code and have your first peek of the application.

 

↑ Return to Top


 

2.5. Working with Integrated Terminal

In this section, we will demonstrate on changing the Integrated Terminal shell and using the Integrated Terminal to install extension from the marketplace.

 

↑ Return to Top


 

2.5.1. Displaying the Integrated Terminal

In this section, we will discuss about how we can display the Integrated Terminal within Visual Studio Code and view the default shell for the first time.

To do this, you have 2 ways of displaying the Integrated Terminal:

  • Select View > Integrated Terminal
  • CTRL + `

 

Once you have displayed the Integrated Terminal, you will see that the Integrated Terminal default shell is the Command Shell (CMD.exe) as below.

 

↑ Return to Top


 

2.5.2. How to change the default Integrated Terminal to PowerShell

In this section, we will demonstrate on how we can modify the Integrated Terminal configuration to launch PowerShell instead of Command Shell by changing the User Settings in the Visual Studio Code Preferences.

To do this, you can use the Visual Studio Code graphical interface menu:

  • Select File > Preferences > User Settings

 

On the settings.json tab > add the following JSON line within the curly brackets:

    // 64-bit PowerShell if available, otherwise 32-bit

    "terminal.integrated.shell.windows": "C:\Windows\sysnative\WindowsPowerShell\v1.0\powershell.exe"

 

Once you have added the overriding JSON syntax into setting.json file, you will have to save the settings.json and restarted the application.

To do this, you have 2 ways to save the file:

  • Select File > Save
  • CTRL + S

After saving the settings.json, you will have to exit Visual Studio Code and launch Visual Studio Code again.

Once Microsoft Visual Studio Code launched, display the Integrated Terminal again. Now, you will view the Integrated Terminal in PowerShell.

 

↑ Return to Top


 

2.6. Working with Extension

In this section, we will demonstrate how to install the PowerShell extension from the marketplace and improve the Visual Studio Code experience with IntelliSense.

 

↑ Return to Top


 

2.6.1. Installing Microsoft Visual Studio Code PowerShell extension

To install PowerShell extension from Marketplace using Integrated Terminal, we will launch the Integrated Terminal and issue the command below:

# Using the Integrated Terminal, we can install

#  the PowerShell extension by calling code.exe

#  with the appropriate parameter.

code --install-extension ms-vscode.PowerShell

 

Once the PowerShell extension has been installed into Visual Studio Code and restarted the Visual Studio Code, you can test the PowerShell IntelliSense by writing some PowerShell code like the example in the screenshot below.

 

↑ Return to Top


 

2.6.2. List installed Microsoft Visual Studio Code extensions

To list installed extensions using Integrated Terminal, we will launch the Integrated Terminal and issue the command below:

# Using the Integrated Terminal, we can list

#  the installed extension by calling code.exe

#  with the appropriate parameter.

code --list-extensions

 

 

↑ Return to Top


 

2.6.3. Uninstalling a Microsoft Visual Studio Code extension

To uninstall extension using Integrated Terminal, we will launch the Integrated Terminal and issue the command below:

# Using the Integrated Terminal, we can uninstall the

#  Debugger for Chrome extension by calling code.exe

#  with the appropriate parameter.

code --uninstall-extension msjsdiag.debugger-for-chrome

 

 

↑ Return to Top


 

3. Getting Started with GitHub on Visual Studio Code

In this section, we will get started by downloading and installing Git just to get you started on Visual Studio Code with Git integration in order to synchronise with GitHub repositories.

 

↑ Return to Top


 

3.1. Requirement

With Git available in multiple variety of Operating System platform, we high recommend you to find the correct package for your platform from the download site below:

 

↑ Return to Top


 

3.2. Download Git using PowerShell

In this section, we will demonstrate how to download Git for Visual Studio Code using PowerShell on Windows.

# Download Git from

#  https://git-scm.com/downloads

Invoke-WebRequest `

    -Uri 'https://github.com/git-for-windows/git/releases/download/v2.10.0.windows.1/Git-2.10.0-64-bit.exe' `

    -OutFile 'C:\Temp\Git-2.10.0-64-bit.exe' ;

 

↑ Return to Top


 

3.3. Install Git silently using PowerShell

In this section, we will demonstrate how to install Git silently for Visual Studio Code using PowerShell on Windows. You can also refer to the setup resource for Windows operating system below:

# Begin SILENT installation of

#  Git version 2.10.0 X64

Start-Process `

    -FilePath 'C:\Temp\Git-2.10.0-64-bit.exe' `

    -ArgumentList '/SILENT /LOG="C:\Temp\GitSetup.log"' ;

 

 

↑ Return to Top


 

3.4. Use Git to clone a repository from GitHub

With Git and Visual Studio Code installed, we will demonstrate how to clone the Open Source PowerShell repository in GitHub using Integrated Terminal (PowerShell) or PowerShell console to your local disk and open the folder to view the entire Open Source PowerShell source code locally.

# Navigate to Git bin folder

Set-Location `

    -Path 'C:\Program Files\Git\bin' ;

 

# Use Git to clone the PowerShell Repository

#  from GitHub to local personal folder

Git clone https://github.com/PowerShell/PowerShell.git "$Env:USERPROFILE\Documents\Visual Studio Code\PowerShell"

 

 

Once the Git clone of the GitHub's PowerShell repository has completed and you have open the folder using Visual Studio Code using the Visual Studio Code's menu:

  1. Select File > Open Folder…
  2. Select the cloned repository folder

 

↑ Return to Top


 

4. Conclusion

After you have open the folder using Visual Studio Code, you will be able to use Visual Studio Code to view and work with the source code or even contribute to the PowerShell community through GitHub.

Welcome to the new Open Source Microsoft community, we have got you started with Visual Studio Code. If you think you can improve Visual Studio Code application further, we will welcome your feedback in GitHub (Microsoft/vscode).

 

↑ Return to Top


 

5. Reference

 

↑ Return to Top


 

6. See Also

 

↑ Return to Top