安装Windows PowerShell

Windows PowerShell 默认安装在所有 Windows 中,从 Windows 7 SP1 和 Windows Server 2008 R2 SP1 开始。

在 Windows 11、10、8.1、8.0 和 7 中寻找 PowerShell

有时在Windows中定位PowerShell控制台或集成脚本环境(ISE)会比较困难,因为其位置会从一个版本转移到另一个版本。

以下表格应能帮助你在Windows版本中找到PowerShell。 这里列出的所有版本均为发布时的原始版本,未做任何更新。

主机版

  • 对于Windows 10和11——点击Windows图标(Windows 10在左下角,Windows 11在中下方),开始输入PowerShell。
  • 对于Windows 8.1——在开始界面开始输入PowerShell。 如果是在桌面,点击左下角的Windows图标,开始输入PowerShell。

对于ISE来说

  • 对于Windows 10和11——点击Windows图标(Windows 10在左下角,Windows 11在中下方),开始输入ISE。
  • 对于Windows 8.1——在开始界面输入 PowerShell ISE。 如果在桌面,点击左下角的Windows图标,输入 PowerShell ISE

在 Windows Server 版本中查找 PowerShell

从 Windows Server 2008 R2 开始,Windows作系统可以在没有图形用户界面(GUI)的情况下安装。 没有图形界面的 Windows Server 版本称为 核心 版,带有图形界面的版本称为 桌面版。

Windows Server 核心版

在所有核心版本中,登录服务器时会显示Windows命令提示符窗口。

在命令提示符会话中输入 powershell 并按 回车 键启动PowerShell。 输入 exit 关闭PowerShell会话并返回命令提示符。

Windows Server 桌面版

在所有桌面版本中,点击左下角的Windows图标,开始输入PowerShell。 你既有主机版,也有ISE版。

上述规则的唯一例外是Windows Server 2008 R2 SP1中的ISE系统。 在这种情况下,点击Windows左下角图标,输入PowerShell ISE。

如何检查PowerShell的版本

要查找你安装的PowerShell版本,启动PowerShell控制台(或ISE),输入$PSVersionTable并按ENTER。 关注价值 PSVersion

升级现有的 Windows PowerShell

PowerShell的安装包包含在一个WMF安装程序中。 WMF 安装程序的版本与 PowerShell 版本一致。 Windows PowerShell 没有独立安装程序。

如果你需要在Windows中更新现有版本的PowerShell,请使用以下表格查找你想更新的PowerShell版本的安装程序。

Windows操作系统 PS 3.0 PS 4.0 PS 5.0 PS 5.1
Windows 11
Windows Server 2022
- - - 安装
Windows 10(见注释1)
Windows Server 2016
- - - 安装
Windows 8.1
Windows Server 2012 R2
- 安装 不支持 WMF 5.1
Windows 8操作系统
Windows Server 2012
安装 不支持 不支持 WMF 5.1
Windows 7 SP1
Windows Server 2008 R2 SP1
不支持 不支持 不支持 WMF 5.1

注释

在Windows 10的初始版本中,启用自动更新后,PowerShell版本从5.0升级到5.1。 如果Windows 10的原始版本没有通过Windows更新进行更新,那么PowerShell版本将是5.0。

Need Azure PowerShell

如果你在找 Azure PowerShell,可以先从《 Azure PowerShell概览》开始。

另请参阅