Windows11安装PowerShell 7

安装

1. 安装 Windows Terminal 和 PowerShell 7

打开 Windows 商店(Microsoft Store),搜索并安装以下两个软件。

  • 搜索并安装 Windows Terminal。这个Windows11默认是安装好了,可以忽略安装。
  • 搜索并安装 PowerShell (图标是黑色的,不是蓝色的)。

Ps:

对,你截图里的这个就是 PowerShell 7,而且是微软官方发布的版本。

从截图可以确认:

  • 发布者:Microsoft Corporation
  • 版本:v7.6.3
  • 应用类型:开发人员工具 ✅

它对应的命令是:

pwsh.exe

不是 Windows 自带的:

powershell.exe

两者不会冲突,会并存:

Windows 11
│
├── Windows PowerShell 5.1
│      命令:powershell.exe
│      路径:
│      C:\Windows\System32\WindowsPowerShell\v1.0\
│
└── PowerShell 7.6.3
       命令:pwsh.exe
       路径:
       C:\Program Files\PowerShell\7\

安装后你可以验证:

打开新的 PowerShell 7:

$PSVersionTable

应该看到:

PSVersion   7.6.3
PSEdition   Core

然后在旧 PowerShell 5.1 里:

$PSVersionTable

仍然会显示:

PSVersion   5.1.x
PSEdition   Desktop

不会覆盖,也不会影响系统。

安装完成打开

配置 Windows Terminal

  • 搜索“终端”,右键选择“固定到任务栏”。后续使用时,直接从任务栏单击即可打开。
  • 打开”终端”,进入设置。将默认配置改为刚安装的 PowerShell,并将启动目录设置为日常工作目录(尽量不要放在 C 盘下)。
  • 修改默认启动

Ps:

安装好之后这里没有

这是正常情况。你现在 Windows Terminal 里只显示:

  • Windows PowerShell(5.1)
  • 命令提示符
  • Azure Cloud Shell

说明 Windows Terminal 还没有检测到 PowerShell 7 的配置文件

先确认 PowerShell 7 是否安装成功。

打开「运行」(Win + R),输入:

pwsh

如果能打开,并显示类似:

PowerShell 7.6.3

说明安装正常。


然后让 Windows Terminal 重新扫描:

方法 1(最简单)

  1. 完全关闭所有 Windows Terminal
  2. 重新打开

 

参考:

https://www.bilibili.com/video/BV1S3MT64EXn/

Windows Terminal:现代化命令行方案 – BrotherHong

作者: 高志远

高志远,24岁,男生

发表评论

邮箱地址不会被公开。