You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何修改PowerShell默认路径?解决Scoop安装后系统仍指向旧版本问题

解决Scoop安装的新版PowerShell无法被系统及终端识别的问题

用户当前命令查找结果:

where.exe Powershell
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
where.exe pwsh
E:\Apps\scoop\apps\powershell\current\pwsh.exe
E:\Apps\scoop\shims\pwsh.exe

一、让powershell命令默认指向新版PowerShell

方式1:调整环境变量顺序

  • 打开系统环境变量设置:右键「此电脑」→「属性」→「高级系统设置」→「环境变量」
  • 在「用户变量」或「系统变量」的Path列表中,将E:\Apps\scoop\shims条目拖动到C:\Windows\System32\WindowsPowerShell\v1.0之前
  • 重启所有终端窗口,运行where.exe powershell验证,此时应优先返回Scoop shims路径下的命令

方式2:创建Scoop别名

在PowerShell中执行以下命令,将powershell映射为pwsh的别名:

scoop alias add powershell pwsh

二、配置Windows Terminal使用新版PowerShell

  1. 打开Windows Terminal设置(快捷键Ctrl+,)
  2. 点击左下角「打开JSON文件」编辑配置
  3. 找到旧版PowerShell的配置项,修改commandline字段为新版路径:
    "commandline": "E:\\Apps\\scoop\\apps\\powershell\\current\\pwsh.exe"
    
    若已调整环境变量,直接写"pwsh.exe"即可
  4. 可将该配置项设置为默认终端配置文件

三、配置VS Code使用新版PowerShell

  1. 打开VS Code设置(快捷键Ctrl+,)
  2. 搜索terminal.integrated.profiles.windows,点击「编辑settings.json」
  3. 修改PowerShell的配置路径:
    "terminal.integrated.profiles.windows": {
        "PowerShell": {
            "path": "E:\\Apps\\scoop\\apps\\powershell\\current\\pwsh.exe",
            "source": "PowerShell"
        }
    }
    
  4. 搜索powershell.powerShellExePath,将其值设置为新版pwsh.exe的路径,确保PowerShell扩展也使用新版

完成以上步骤后,重启所有应用即可生效。

内容的提问来源于stack exchange,提问作者Flamingo

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.18 13:42:44