Skip to content

Commit 9f223b0

Browse files
TylerLeonhardtsdwheeler
authored andcommitted
Update docs on how to add your own powershell executables (#4312)
* Update docs on how to add your own powershell executables * Update using-vscode.md
1 parent 326b97d commit 9f223b0

File tree

1 file changed

+71
-15
lines changed

1 file changed

+71
-15
lines changed

reference/docs-conceptual/components/vscode/using-vscode.md

Lines changed: 71 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -83,27 +83,83 @@ You are prompted with "Do you want to run software from this untrusted publisher
8383
Type `R` to run the file. Then, open Visual Studio Code and check that the PowerShell extension is
8484
functioning properly. If you still have issues getting started, let us know on [GitHub](https://github.com/PowerShell/vscode-powershell/issues).
8585

86-
#### Using a specific installed version of PowerShell
86+
#### Choosing a version of PowerShell to use with the extension
8787

88-
If you wish to use a specific installation of PowerShell with Visual Studio Code, you need to add a new variable to your user settings file.
88+
With PowerShell Core installing side-by-side with Windows PowerShell, is it now possible to a
89+
particular version of PowerShell with the PowerShell extension. Use the following these steps to
90+
choose the version:
8991

90-
1. Click **File -> Preferences -> Settings**
91-
1. Two editor panes appear.
92-
In the right-most pane (`settings.json`), insert the setting below appropriate for your OS somewhere between the two curly brackets (`{` and `}`) and replace **\<version\>** with the installed PowerShell version:
92+
1. Open the command pallet (<kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>P</kbd> on Windows & Linux,
93+
<kbd>Cmd</kbd>+<kbd>Shift</kbd>+<kbd>P</kbd> on macOS).
94+
1. Search for "Session".
95+
1. Click on "PowerShell: Show Session Menu".
96+
1. Choose the version of PowerShell you want to use from the list - for example, "PowerShell Core".
9397

94-
```json
95-
// On Windows:
96-
"powershell.powerShellExePath": "c:/Program Files/PowerShell/<version>/pwsh.exe"
98+
>[!IMPORTANT]
99+
> This feature looks at a few well-known paths on different operating systems to discover install
100+
> locations of PowerShell. If you installed PowerShell to a non-typical location, it might not show
101+
> up initially in the Session Menu. You can extend the session menu by [adding your own custom paths](#adding-your-own-powershell-paths-to-the-session-menu)
102+
> as described below.
97103
98-
// On Linux:
99-
"powershell.powerShellExePath": "/opt/microsoft/powershell/<version>/pwsh"
104+
>[!NOTE]
105+
> There is another way to get to the session menu. When a PowerShell file is open in your editor, you
106+
> see a green version number in the bottom right. Clicking this version number will bring you to the
107+
> session menu.
100108
101-
// On macOS:
102-
"powershell.powerShellExePath": "/usr/local/microsoft/powershell/<version>/pwsh"
103-
```
109+
##### Adding your own PowerShell paths to the session menu
104110

105-
1. Replace the setting with the path to the desired PowerShell executable
106-
1. Save the settings file and restart Visual Studio Code
111+
You can add other PowerShell executable paths to the session menu through a VS Code setting.
112+
113+
Add an item to the list `powershell.powerShellAdditionalExePaths` or create the list if it doesn't
114+
exist in your `settings.json`:
115+
116+
```json
117+
{
118+
// other settings...
119+
120+
"powershell.powerShellAdditionalExePaths": [
121+
{
122+
"exePath": "C:\\Users\\tyler\\Downloads\\PowerShell\\pwsh.exe",
123+
"versionName": "Downloaded PowerShell"
124+
}
125+
],
126+
127+
// other settings...
128+
}
129+
```
130+
131+
Each item must have:
132+
133+
* `exePath`: The path to the `pwsh` or `powershell` executable.
134+
* `versionName`: The text that will show up in the session menu.
135+
136+
You can set the default PowerShell version to use using the `powershell.powerShellDefaultVersion` setting
137+
by setting this to the text displayed in the session menu (aka the `versionName` in the last setting):
138+
139+
```json
140+
{
141+
// other settings...
142+
143+
"powershell.powerShellAdditionalExePaths": [
144+
{
145+
"exePath": "C:\\Users\\tyler\\Downloads\\PowerShell\\pwsh.exe",
146+
"versionName": "Downloaded PowerShell"
147+
}
148+
],
149+
150+
"powershell.powerShellDefaultVersion": "Downloaded PowerShell",
151+
152+
// other settings...
153+
}
154+
```
155+
156+
Once you've set this setting, restart Visual Studio Code or use the the "Developer: Reload Window" command
157+
pallet action to reload the current vscode window.
158+
159+
If you open the session menu, you will now see your additional PowerShell versions!
160+
161+
> [!NOTE]
162+
> If you build PowerShell from source, this is a great way to test out your local build of PowerShell.
107163
108164
#### Configuration settings for Visual Studio Code
109165

0 commit comments

Comments
 (0)