PowerShell ISE:如何运行新版本的PowerShell

19

如何让PowerShell ISE与PowerShell 6.0一起使用,目前只有4.0。

这个服务器安装了PowerShell 4.0,我从此链接https://github.com/PowerShell/PowerShell/releases下载并安装了PowerShell-6.1.0-win-x64.msi。现在文件存在于C:\Program Files\PowerShell\6。

然而,ISE仍然显示4.0,但我需要它运行6.0

$PSVersionTable.psversion

Major Minor Build Revision

4 0 -1 -1


5
无法让ISE运行PowerShell Core 6.0。 - Mike Shepard
2个回答

12

PowerShell有三个可执行文件...

仅限Windows平台...

  • PowerShell_ISE.exe = ISE v2 - v5.1
  • powershell.exe = consolehost v1 - 5.1

注:(没有新版本发布,但是根据微软的声明,此版本将会得到持续支持,只会修复漏洞/安全问题。)

跨平台

  • pwsh.exe = PowerShell Core/v6

如果您正在使用v6,则应使用Visual Studio Code作为编辑器,它与ISE不同,也是跨平台的。

https://code.visualstudio.com/Download

没有计划使ISE利用pwsh.exe/PSCore。

但是,您可以继续使用ISE,并且如果需要特定于PSCore的功能,必须像运行cmd.exe一样运行pwsh.exe。您的代码将在pwsh.exe控制台中运行,并根据您启动它的方式返回到ISE。


7
您使用的是Windows PowerShell ISE,它始终将Windows PowerShell作为集成Shell,您需要在这里使用VSCode,在其中可以选择要使用的PowerShell版本...

只需在“文件”->“首选项”->“设置”中更改以下项目即可。

"terminal.integrated.shell.windows": "C:\\Program Files\\PowerShell\\pwsh.exe"

同样可以通过几个点击在用户界面上完成...

1
设置terminal.integrated.shell.windows不会影响语言服务器。该设置的是powershell.powerShellExePath - Patrick Meinecke

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接