-1

Running in Windows 11 Pro 64, I've installed PowerShell 7 and VS Code. I'm able to run PS 7 directly in Windows, which brings up a window titled "PowerShell 7 (x64)". In VS Code, I installed the PowerShell extension. When I run VS Code, I'm able to run Windows PowerShell 5.1, but PS 7 does not appear to be available.

I know VS Code is running PS 5.1 and not 7 because when I call Get-Content ... -AsByteStream, it does recognize the parameter AsByteStream.

In VS Code, under "Get Started with PowerShell", there's an item, "Switch Sessions", which says, "To switch between PowerShell 7 and Windows PowerShell 5.1, use the menu: 'Open PowerShell Sessions Menu'" When I click on that button, I get a menu at the top that offers two versions of Windows PowerShell, but no PS 7, as shown in the following display image:

enter image description here

What do I need to do to run PS 7 here?

NewSites
  • 1,402
  • 2
  • 11
  • 26
  • How about "terminal.integrated.shell.windows": "c:/Program Files/PowerShell/7/pwsh.exe" in settings? – Severin Pappadeux Aug 12 '23 at 00:21
  • @SeverinPappadeux - I don't know how to follow your suggestion. I went to "Settings > Terminal" and didn't see the setting you mention. I also searched Settings for "integrated.shell" and for "pwsh" and found nothing that seems relevant. Am I missing something? – NewSites Aug 12 '23 at 00:40
  • ok, learned that this was deprecated, sorry to misled you. Looks like this is how it is supposed to be done, on per-workspace basis. https://github.com/microsoft/vscode/issues/123069 – Severin Pappadeux Aug 12 '23 at 01:44
  • @SeverinPappadeux - You say "this is how it is supposed to be done". Are you saying that there is something on that issue page that I'm supposed to do? Am I supposed to learn about VS Code workspaces? I followed the installation instructions carefully and there was nothing about workspaces. – NewSites Aug 12 '23 at 02:18
  • "Am I supposed to learn about VS Code workspaces?" Yes, if you're serious about soft.development with vs code. Workspace is basically folder (with sufolders) open in VS Code, root of your project. https://code.visualstudio.com/docs/editor/workspaces – Severin Pappadeux Aug 12 '23 at 03:18
  • Okay, I read that. It doesn't seem to have anything to do with why PS 7 is not available. Is there something on the issue page you sent that is relevant to that problem? – NewSites Aug 12 '23 at 12:33

1 Answers1

0

Solution found at GitHub.

The problem was that I had installed PS 7 in a custom location, so VS Code didn't know where to look for it.

Solution was to add a VS Code setting: powershell.powerShellAdditionalExePaths with the value being the full filespec of the PS executable, pwsh.exe.

After adding that, the key of that setting appeared in the sessions menu, which allowed me to switch to PS 7, and the parameter AsByteStream was recognized in my script.

NewSites
  • 1,402
  • 2
  • 11
  • 26