@@ -4,39 +4,50 @@ Area: languages
44TOCTitle : PowerShell
55ContentId : 8688bb6d-793e-4a37-aed2-5af4cfe89940
66PageTitle : PowerShell editing with Visual Studio Code
7- DateApproved : 02/06 /2025
7+ DateApproved : 02/20 /2025
88MetaDescription : Learn about using PowerShell in Visual Studio Code
99---
1010# PowerShell in Visual Studio Code
1111
12- [ PowerShell] [ 20 ] is a task-based command-line shell and scripting language built on [ .NET] [ 19 ] that
12+ [ PowerShell] [ 24 ] is a task-based command-line shell and scripting language built on [ .NET] [ 23 ] that
1313provides a powerful toolset for administrators on any platform.
1414
15- The Microsoft [ PowerShell] [ 27 ] extension for Visual Studio Code (VS Code) provides rich language
15+ The Microsoft [ PowerShell] [ 31 ] extension for Visual Studio Code (VS Code) provides rich language
1616support and capabilities such as syntax completions, definition tracking, and linting for
17- PowerShell. The extension should work anywhere VS Code itself and PowerShell Core 7.2 or higher is
18- [ supported] [ 14 ] . For Windows PowerShell, only version 5.1 is supported and only on a best-effort
19- basis. PowerShell Core 6, 7.0, and 7.1 have reached end-of-support. We test the following
20- configurations:
17+ PowerShell. The extension should work everywhere VS Code is supported using
18+ [ PowerShell 7+ currently supported versions] [ 17 ] .
2119
22- - ** Windows Server 2022** with Windows PowerShell 5.1 and PowerShell 7.2
23- - ** Windows Server 2019** with Windows PowerShell 5.1 and PowerShell 7.2
24- - ** macOS 11** with PowerShell Core 7.2
25- - ** Ubuntu 20.04** with PowerShell Core 7.2
20+ Support for Windows PowerShell 5.1 is provided on a best effort basis. [ .NET Framework 4.8] [ 18 ] or
21+ higher is required.
22+
23+ [ VS Code Remote Development] [ 13 ] Environments, including [ GitHub Codespaces] [ 19 ] and
24+ [ VS Code Server] [ 14 ] are supported.
25+
26+ > [ !IMPORTANT]
27+ > [ Visual Studio Code for the Web] [ 12 ] is only supported for limited functionality such as basic
28+ > syntax highlighting, as the PowerShell engine can't run in this environment.
29+
30+ We actively test the following configurations:
31+
32+ - ** Windows Server 2022** with Windows PowerShell 5.1 and PowerShell 7+
33+ - ** macOS 14.7** with PowerShell 7+
34+ - ** Ubuntu 24.04** with PowerShell 7+
35+
36+ On Windows, we also test with and without Constrained Language Mode enabled.
2637
2738## Installing the PowerShell extension
2839
2940The PowerShell extension can be installed from the Visual Studio Code Marketplace by clicking the
30- [ Install Button] [ 41 ] . You can also install the PowerShell extension from within VS Code by opening
41+ [ Install Button] [ 44 ] . You can also install the PowerShell extension from within VS Code by opening
3142the ** Extensions** view with keyboard shortcut ` kb(workbench.view.extensions) ` , typing _ PowerShell_ ,
3243and selecting the PowerShell extension:
3344
34- ![ PowerShell extension] [ 37 ]
45+ ![ PowerShell extension] [ 40 ]
3546
3647## Major features
3748
38- - [ Syntax highlighting] [ 15 ]
39- - Advanced built-in [ code snippets] [ 06 ]
49+ - [ Syntax highlighting] [ 20 ]
50+ - Advanced built-in [ code snippets] [ 08 ]
4051- [ IntelliSense] [ 05 ] for cmdlets and more
4152- [ Problems] [ 09 ] reported by [ PowerShell Script Analyzer] [ 11 ]
4253- [ Go to Definition] [ 02 ] of cmdlets, variables, classes and more
@@ -45,21 +56,21 @@ and selecting the PowerShell extension:
4556- Symbol-based [ Outline View] [ 10 ]
4657- Run selected PowerShell code in current terminal using ` kbstyle(F8) `
4758- Launch online help for the symbol under the cursor using ` kbstyle(Ctrl + F1) `
48- - PowerShell [ Debugger] [ 25 ] integration
59+ - PowerShell [ Debugger] [ 29 ] integration
4960- An Extension Terminal that can interact with the debugger (try ` Set-PSBreakpoint ` !)
50- - PowerShell ISE theme findable in the [ theme picker] [ 08 ]
61+ - PowerShell ISE theme available in the [ theme picker] [ 07 ]
5162- Also try ISE mode using ` kb(workbench.action.showCommands) ` then search for "Enable ISE Mode"
5263
5364### Debugging
5465
5566The PowerShell extension uses the built-in [ debugging interface] [ 01 ] of VS Code to allow for
5667debugging of PowerShell scripts and modules. For more information about debugging PowerShell, see
57- [ Using VS Code] [ 25 ] .
68+ [ Using VS Code] [ 29 ] .
5869
5970### Multi-version support
6071
6172You can configure the PowerShell extension to use any supported version of PowerShell installed on
62- your machine by following [ these instructions] [ 24 ] .
73+ your machine by following [ these instructions] [ 28 ] .
6374
6475Or run the ** PowerShell: Show Session Menu** command from the Command Palette
6576(` kb(workbench.action.showCommands) ` ).
@@ -73,22 +84,22 @@ CodeLens features include:
7384
7485- Pester ** Run tests** and ** Debug tests** .
7586
76- ![ Pester CodeLens Integration] [ 36 ]
87+ ![ Pester CodeLens Integration] [ 39 ]
7788
7889- Pester symbol support
7990
80- ![ CodeLens Pester Symbol Support] [ 34 ]
91+ ![ CodeLens Pester Symbol Support] [ 38 ]
8192
8293- Function, variable, class, and other symbol references
8394
8495 CodeLens reference support shows the number of times a symbol is referenced within your
8596 code and allows you to jump to specific references.
8697
87- ![ CodeLens Function Reference Support] [ 33 ]
98+ ![ CodeLens Function Reference Support] [ 37 ]
8899
89100### PSScriptAnalyzer integration
90101
91- [ PSScriptAnalyzer] [ 26 ] is a PowerShell module that provides a static source code checker for modules
102+ [ PSScriptAnalyzer] [ 30 ] is a PowerShell module that provides a static source code checker for modules
92103and scripts. ** PSScriptAnalyzer** has rules that verify the quality of PowerShell code. These rules
93104are based on PowerShell best practices identified by the PowerShell Team and the community.
94105** PSScriptAnalyzer** generates diagnostic records (errors and warnings) to inform users about
@@ -106,49 +117,38 @@ To disable **PSScriptAnalyzer**, open your settings (`kb(workbench.action.openSe
106117** Extensions** , select the ** PowerShell** extension, and deselect the checkbox for ** Script
107118Analysis: Enable** (` powershell.scriptAnalysis.enable ` ).
108119
109- ![ PSScriptAnalyzer Settings] [ 39 ]
120+ ![ PSScriptAnalyzer Settings] [ 42 ]
110121
111122** PSScriptAnalyzer** also provides code formatting. You can invoke automatic document formatting
112123with the ** Format Document** command or the (` kb(editor.action.formatDocument) ` ) keyboard shortcut.
113124
114125### Pester integration
115126
116- [ Pester] [ 29 ] is a framework for running unit tests to execute and Windows PowerShell 5.1 comes with
127+ [ Pester] [ 33 ] is a framework for running unit tests to execute and Windows PowerShell 5.1 comes with
117128** Pester** 3.40 preinstalled. To update ** Pester** or to install the latest version on other
118- platforms, follow the [ Pester installation instructions] [ 30 ] .
119-
120- ### Plaster integration
121-
122- [ Plaster] [ 16 ] is a template-based file and project generator written in PowerShell. Its purpose is
123- to streamline the creation of PowerShell module projects, Pester tests, DSC Configurations and more.
124-
125- The PowerShell extension allows the creation of new Plaster projects using the ** PowerShell: Create
126- New Project from Plaster Template** command from the Command Palette
127- (` kb(workbench.action.showCommands) ` ).
128-
129- ![ Plaster Project] [ 35 ]
129+ platforms, follow the [ Pester installation instructions] [ 34 ] .
130130
131131## PowerShell extension settings
132132
133- You can customize VS Code [ settings] [ 07 ] from the ** File** > ** Preferences** > ** Settings** menu item.
133+ You can customize VS Code [ settings] [ 06 ] from the ** File** > ** Preferences** > ** Settings** menu item.
134134
135135You can also select the gear icon located in the lower left corner of the Activity Bar.
136136
137- ![ codeGear] [ 32 ]
137+ ![ codeGear] [ 36 ]
138138
139139You can also use the keyboard shortcut ` kb(workbench.action.openSettings) ` to open your settings.
140140You can still open the ` settings.json ` file using ** Preferences: Open User Settings (JSON)** command from
141141the Command Palette (` kb(workbench.action.showCommands) ` ) or by changing the default settings editor
142142with the ` "workbench.settings.editor" ` setting.
143143
144- Go to [ User and Workspace settings] [ 07 ] for more information on configuring VS Code settings.
144+ Go to [ User and Workspace settings] [ 06 ] for more information on configuring VS Code settings.
145145
146146### Types.ps1xml and Format.ps1xml files
147147
148148PowerShell ` .ps1xml ` files are used to extend the type system and define output formatting. For more
149- information on these files, see the official PowerShell documentation on [ Types.ps1xml] [ 22 ] and
150- [ Format.ps1xml] [ 21 ] . You can get IntelliSense features when authoring ` .ps1xml ` files by installing
151- the [ XML extension by Red Hat] [ 28 ] . After installing, add this configuration to your user settings:
149+ information on these files, see the official PowerShell documentation on [ Types.ps1xml] [ 26 ] and
150+ [ Format.ps1xml] [ 25 ] . You can get IntelliSense features when authoring ` .ps1xml ` files by installing
151+ the [ XML extension by Red Hat] [ 32 ] . After installing, add this configuration to your user settings:
152152
153153``` json
154154"xml.fileAssociations" : [
@@ -192,19 +192,19 @@ code (Get-ChildItem ~\.vscode\extensions\ms-vscode.PowerShell-*\examples)[-1]
192192You can also open the examples from the Command Palette (` kb(workbench.action.showCommands) ` ) with
193193the ** PowerShell: Open Examples Folder** command.
194194
195- ![ Open PowerShell Examples] [ 40 ]
195+ ![ Open PowerShell Examples] [ 43 ]
196196
197197## Additional resources
198198
199- There are more detailed articles in the PowerShell documentation. Start with [ Using VS Code] [ 23 ] .
199+ There are more detailed articles in the PowerShell documentation. Start with [ Using VS Code] [ 27 ] .
200200
201- Check out the [ troubleshooting guide] [ 17 ] for answers to common questions.
201+ Check out the [ troubleshooting guide] [ 21 ] for answers to common questions.
202202
203203For more information on debugging, check out the _ Hey, Scripting Guy!_ two-part blog post series
204- written by [ @keithHill ] [ 31 ] on debugging with the PowerShell extension:
204+ written by [ @keithHill ] [ 35 ] on debugging with the PowerShell extension:
205205
206- - [ Debugging PowerShell script in Visual Studio Code - Part 1] [ 12 ]
207- - [ Debugging PowerShell script in Visual Studio Code - Part 2] [ 13 ]
206+ - [ Debugging PowerShell script in Visual Studio Code - Part 1] [ 15 ]
207+ - [ Debugging PowerShell script in Visual Studio Code - Part 2] [ 16 ]
208208
209209## Testing new features and providing feedback
210210
@@ -215,49 +215,52 @@ by using the **Switch to Release Version** button that will appear. You can also
215215to other versions of the extension using the arrow next to the ** Uninstall** button and
216216choosing ** Install Another Version...** .
217217
218- ![ Screenshot showing the button to switch to a pre-release version.] [ 38 ]
218+ ![ Screenshot showing the button to switch to a pre-release version.] [ 41 ]
219219
220- If you find a bug, [ open an issue] [ 18 ] and revert to the stable version while we fix it.
220+ If you find a bug, [ open an issue] [ 22 ] and revert to the stable version while we fix it.
221221
222222<!-- link references -->
223223[ 01 ] : /docs/editor/debugging
224224[ 02 ] : /docs/editor/editingevolved#_go-to-definition
225225[ 03 ] : /docs/editor/editingevolved#_open-symbol-by-name
226226[ 04 ] : /docs/editor/editingevolved#_reference-information
227227[ 05 ] : /docs/editor/intellisense
228- [ 06 ] : /docs/editor/userdefinedsnippets
229- [ 07 ] : /docs/editor/settings
230- [ 08 ] : /docs/editor/themes
228+ [ 06 ] : /docs/editor/settings
229+ [ 07 ] : /docs/editor/themes
230+ [ 08 ] : /docs/editor/userdefinedsnippets
231231[ 09 ] : /docs/getstarted/tips-and-tricks#_errors-and-warnings
232232[ 10 ] : /docs/getstarted/userinterface#_outline-view
233233[ 11 ] : http://github.com/PowerShell/PSScriptAnalyzer
234- [ 12 ] : https://devblogs.microsoft.com/scripting/debugging-powershell-script-in-visual-studio-code-part-1/
235- [ 13 ] : https://devblogs.microsoft.com/scripting/debugging-powershell-script-in-visual-studio-code-part-2/
236- [ 14 ] : https://docs.microsoft.com/en-us/powershell/scripting/powershell-support-lifecycle
237- [ 15 ] : https://github.com/PowerShell/EditorSyntax
238- [ 16 ] : https://github.com/PowerShell/Plaster
239- [ 17 ] : https://github.com/PowerShell/vscode-powershell/blob/main/docs/troubleshooting.md#troubleshooting-powershell-extension-issues
240- [ 18 ] : https://github.com/PowerShell/vscode-powershell/issues/new/choose
241- [ 19 ] : https://learn.microsoft.com/dotnet
242- [ 20 ] : https://learn.microsoft.com/powershell/
243- [ 21 ] : https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_format.ps1xml
244- [ 22 ] : https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_types.ps1xml
245- [ 23 ] : https://learn.microsoft.com/powershell/scripting/dev-cross-plat/vscode/using-vscode
246- [ 24 ] : https://learn.microsoft.com/powershell/scripting/dev-cross-plat/vscode/using-vscode#choosing-a-version-of-powershell-to-use-with-the-extension
247- [ 25 ] : https://learn.microsoft.com/powershell/scripting/dev-cross-plat/vscode/using-vscode#debugging-with-visual-studio-code
248- [ 26 ] : https://learn.microsoft.com/powershell/utility-modules/psscriptanalyzer/overview
249- [ 27 ] : https://marketplace.visualstudio.com/items?itemName=ms-vscode.PowerShell
250- [ 28 ] : https://marketplace.visualstudio.com/items?itemName=redhat.vscode-xml
251- [ 29 ] : https://pester.dev/
252- [ 30 ] : https://pester.dev/docs/introduction/installation
253- [ 31 ] : https://twitter.com/r_keith_hill
254- [ 32 ] : images/powershell/codeGear.png
255- [ 33 ] : images/powershell/codeLensFuncRef.gif
256- [ 34 ] : images/powershell/codeLensPesterSymbol.gif
257- [ 35 ] : images/powershell/cpPlasterCommand.png
258- [ 36 ] : images/powershell/pesterCodeLens.png
259- [ 37 ] : images/powershell/PowerShellExtension.png
260- [ 38 ] : images/powershell/prerelease-switch.png
261- [ 39 ] : images/powershell/pssaExtensionSetting.png
262- [ 40 ] : images/powershell/pwshExamples.png
263- [ 41 ] : vscode:extension/ms-vscode.PowerShell
234+ [ 12 ] : https://code.visualstudio.com/docs/editor/vscode-web
235+ [ 13 ] : https://code.visualstudio.com/docs/remote/remote-overview
236+ [ 14 ] : https://code.visualstudio.com/docs/remote/vscode-server
237+ [ 15 ] : https://devblogs.microsoft.com/scripting/debugging-powershell-script-in-visual-studio-code-part-1/
238+ [ 16 ] : https://devblogs.microsoft.com/scripting/debugging-powershell-script-in-visual-studio-code-part-2/
239+ [ 17 ] : https://docs.microsoft.com/en-us/powershell/scripting/powershell-support-lifecycle
240+ [ 18 ] : https://dotnet.microsoft.com/download/dotnet-framework
241+ [ 19 ] : https://github.com/features/codespaces
242+ [ 20 ] : https://github.com/PowerShell/EditorSyntax
243+ [ 21 ] : https://github.com/PowerShell/vscode-powershell/blob/main/docs/troubleshooting.md#troubleshooting-powershell-extension-issues
244+ [ 22 ] : https://github.com/PowerShell/vscode-powershell/issues/new/choose
245+ [ 23 ] : https://learn.microsoft.com/dotnet
246+ [ 24 ] : https://learn.microsoft.com/powershell/
247+ [ 25 ] : https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_format.ps1xml
248+ [ 26 ] : https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_types.ps1xml
249+ [ 27 ] : https://learn.microsoft.com/powershell/scripting/dev-cross-plat/vscode/using-vscode
250+ [ 28 ] : https://learn.microsoft.com/powershell/scripting/dev-cross-plat/vscode/using-vscode#choosing-a-version-of-powershell-to-use-with-the-extension
251+ [ 29 ] : https://learn.microsoft.com/powershell/scripting/dev-cross-plat/vscode/using-vscode#debugging-with-visual-studio-code
252+ [ 30 ] : https://learn.microsoft.com/powershell/utility-modules/psscriptanalyzer/overview
253+ [ 31 ] : https://marketplace.visualstudio.com/items?itemName=ms-vscode.PowerShell
254+ [ 32 ] : https://marketplace.visualstudio.com/items?itemName=redhat.vscode-xml
255+ [ 33 ] : https://pester.dev/
256+ [ 34 ] : https://pester.dev/docs/introduction/installation
257+ [ 35 ] : https://twitter.com/r_keith_hill
258+ [ 36 ] : images/powershell/codeGear.png
259+ [ 37 ] : images/powershell/codeLensFuncRef.gif
260+ [ 38 ] : images/powershell/codeLensPesterSymbol.gif
261+ [ 39 ] : images/powershell/pesterCodeLens.png
262+ [ 40 ] : images/powershell/PowerShellExtension.png
263+ [ 41 ] : images/powershell/prerelease-switch.png
264+ [ 42 ] : images/powershell/pssaExtensionSetting.png
265+ [ 43 ] : images/powershell/pwshExamples.png
266+ [ 44 ] : vscode:extension/ms-vscode.PowerShell
0 commit comments