PowerShell 最新安装与升级指南(2025年12月适用)
| 操作系统 | 推荐版本 | 安装/升级方法(最快最简单) | 备注 |
|---|---|---|---|
| Windows 10/11 | PowerShell 7.4+(推荐) 或保留 Windows PowerShell 5.1 | 1. 最推荐:用 winget(自带)winget install --id Microsoft.PowerShell --source winget2. 一键升级最新稳定版 winget upgrade --id Microsoft.PowerShell --source winget | 自动安装 pwsh.exe 不会覆盖旧的 Windows PowerShell 5.1 |
| 3. 微软官方 Microsoft Store(图形化) 搜索 “PowerShell” → 点击安装/更新 | 最适合新手 | ||
| 4. 手动下载 MSI 包(适合企业批量部署) https://github.com/PowerShell/PowerShell/releases | 选择最新 .msi 文件 | ||
| Windows Server 2016–2025 | PowerShell 7.4+ | 同上 winget(Server 2022 以后自带) 或 MSI 离线包 | Server 2016 需要先装 .NET Core 运行时 |
| Linux | PowerShell 7.4+ | 根据发行版一条命令搞定(以下任选其一) “`bash | |
| macOS | PowerShell 7.4+ | Homebrew(推荐)brew install --cask powershell或官方 .pkg 包 | 启动方式:pwsh |
| Docker | 任意版本 | docker run -it mcr.microsoft.com/powershell | 官方镜像 |
安装完成后怎么打开?
| 系统 | 打开方式 |
|---|---|
| Windows | 开始菜单 → “PowerShell 7” 或 Win+R → 输入 pwsh |
| Windows 旧版 | Win+X → “Windows PowerShell” (这是 5.1 版) |
| Linux/macOS | 终端输入 pwsh |
快速验证是否安装成功
pwsh # 进入 PowerShell 7
$PSVersionTable.PSVersion # 查看版本号,2025年12月应 ≥ 7.4.x
强烈建议:把 PowerShell 7 设置成默认终端(Windows 11)
- 打开 Windows Terminal
- 设置 → 配置文件 → 默认配置文件 → 选择 “PowerShell 7”
- 以后 Win+X → Terminal 直接就是最新的 PowerShell 7
常见问题
- Q:装了 PowerShell 7 之后,原来的 Windows PowerShell 5.1 会消失吗?
A:不会!两者完全并存,互不影响。旧脚本继续用powershell.exe,新脚本用pwsh.exe。 - Q:企业禁止 winget 和 Microsoft Store 怎么办?
A:下载离线 MSI 包静默部署即可:msiexec.exe /i PowerShell-7.4.5-win-x64.msi /quiet /norestart
现在 30 秒就能装好最新版 PowerShell 7 了!
装好后告诉我你用的是 Windows 还是 Linux,我马上给你推荐几个“装完就能装逼”的第一波命令~