当前位置:网站首页 > 更多 > 玩电脑 > 正文

[玩转系统] 如何在 Windows 11/10 上安装 PowerShell 7

作者:精品下载站 日期:2024-12-14 19:18:39 浏览:16 分类:玩电脑

如何在 Windows 11/10 上安装 PowerShell 7


默认情况下,从 Windows 7 SP1 和 Windows Server 2008 R2 SP1 开始,每个 Windows 版本都会安装 PowerShell。多年来,微软发布了许多版本的 PowerShell。 Windows PowerShell 基于 .NET Framework 构建,仅适用于 Windows 系统。但最近微软发布了 PowerShell 7.0,该版本可供下载,主要因其跨平台脚本工具而闻名。在这篇文章中,我们将向您展示如何在 Windows 11/10 上安装 PowerShell 7.0。

[玩转系统] 如何在 Windows 11/10 上安装 PowerShell 7

在 Windows 11/10 上安装 PowerShell 7.x

要在 Windows 11/10 上下载并安装 PowerShell 7.0,可以运行 PowerShell cmdlet 从 GitHub 下载并安装 MSI 包。

就是这样:

  • Windows 键 + X 访问高级用户菜单。

  • 按键盘上的 A 以在管理模式下打开 PowerShell。

  • 在 PowerShell 窗口中,复制并粘贴以下 cmdlet,然后按 Enter:

iex "& { $(irm https://aka.ms/install-powershell.ps1) } -UseMSI"

该命令将根据操作系统兼容性直接从 GitHub URL 下载软件包。

MSI 包完全下载后,您将看到设置向导。单击下一步并继续安装过程。

或者,您可以访问 GitHub PowerShell 发布页面并向下滚动资产并选择具有适当架构的操作系统,然后单击下载并安装。

安装完成后,您可以在“开始”菜单中看到该快捷方式。对于 Windows,安装位置为 C:\Program Files\PowerShell

PowerShell 7 安装到新目录,从而能够与 Windows PowerShell 5.1 并行执行。按版本划分的安装位置为:

  • Windows PowerShell 5.1:$env:WINDIR\System32\WindowsPowerShell 1.0

  • PowerShell 6.x:$env:ProgramFiles\PowerShell

  • PowerShell 7:$env:ProgramFiles\PowerShell

您还可以通过运行命令访问PowerShell 7.0。为此,请按 Windows + R 调用“运行”对话框,然后输入 pwsh 并按 Enter 键,此命令将启动新的 PowerShell。

PowerShell 7.0 附带了许多新功能,例如:

  • 管道并行化

  • 新运营商

  • ConciseView 和 Get-Error cmdlet

  • 自动新版本通知

  • 直接从 PowerShell 7 调用 DSC 资源

  • 兼容层。

我们希望您觉得这篇文章有用。<br>

您需要 登录账户 后才能发表评论

取消回复欢迎 发表评论:

关灯