admin 管理员组文章数量: 887017
Microsoft announced PowerShell 7.0 on March 4, 2020. It’s the latest major update to PowerShell, Microsoft’s cross-platform command-line shell and scripting language. Here’s what’s new—and how you can install it on your Windows PC.
Microsoft 于 2020年3月4日发布了 PowerShell 7.0。这是PowerShell的最新重大更新, PowerShell是Microsoft的跨平台命令行外壳和脚本语言。 这是新功能,以及如何在Windows PC上安装它。
PowerShell 7的新增功能? (What’s New in PowerShell 7?)
The latest version, PowerShell 7, builds on the previous PowerShell Core 6.1. It continues to support cross-platform deployment and adds a slew of new features, cmdlets, and bug fixes. Some of the more significant new features include:
最新版本PowerShell 7建立在先前的PowerShell Core 6.1之上。 它继续支持跨平台部署,并增加了许多新功能,cmdlet 和错误修复 。 一些更重要的新功能包括:
Pipeline parallelization with
ForEach-Object
: Iterate through items of a collection in parallel with the new-Parallel
parameter or set a maximum thread count (the default is five) with the-ThrottleLimit
parameters.管道并行使用
ForEach-Object
:通过迭代并行采集的项目与新-Parallel
与参数或设定最大线程数(默认为5个)-ThrottleLimit
参数。The addition of new operators:
增加了新的运算符:
Ternary operator “? : ” : Works much like an if-else statement by comparing two expressions against a condition to see if it’s true or false, e.g.,
Test-Path "C:\Users" ? "exists" : "does not exist"
三元运算符? :”:通过将两个表达式与一个条件进行比较以查看它是真还是假,例如if-else语句,例如
Test-Path "C:\Users" ? "exists" : "does not exist"
Test-Path "C:\Users" ? "exists" : "does not exist"
- Pipeline chain operators “||” and “&&” : The && operator executes the right-hand pipeline if the left-hand pipeline succeeded. Conversely, the || operator only executes the right-hand pipeline if the left-hand pipeline fails. 管道链运营商“ ||” 和“ &&”:如果左侧管道成功,则&&运算符将执行右侧管道。 相反,|| 如果左侧管道失败,则运算符仅执行右侧管道。
The addition of new operators:
增加了新的运算符:
Get-Error
cmdlet: A simplified and dynamic error view for easier investigation of the most recent error in the current session.Get-Error
cmdlet:一种简化的动态错误视图,可以更轻松地调查当前会话中的最新错误。Automatic new version notifications: Notify users when a new version of PowerShell is available. The default update checks once per day for a new release.
自动新版本通知:当有新版本的PowerShell可用时通知用户。 默认更新每天检查一次新版本。
In addition to the new features listed above, Microsoft has added numerous other cmdlets, experimental improvements, and added PowerShell 7 to its Long Term Servicing release, which will enable it to receive updates for as long as .Net 3.1 is supported. A full list of everything new, fixes, and improvements is available from the Github changelog for PowerShell 7.
除了上面列出的新功能之外,Microsoft还添加了许多其他cmdlet,实验性改进,并将PowerShell 7添加到其长期服务版本中,只要支持.Net 3.1,它将使它能够接收更新。 可从PowerShell 7的Github更改日志中获取所有新功能,修复程序和改进功能的完整列表。
如何使用MSI软件包安装PowerShell 7 (How to Install PowerShell 7 with an MSI Package)
PowerShell 7 is available for Windows, macOS, and Linux. We’ll show you how to install it on Windows 10.
PowerShell 7适用于Windows, macOS和Linux 。 我们将向您展示如何在Windows 10上安装它。
The first method we’re going to cover uses an MSI file to install PowerShell. MSI packages work almost identically to an EXE file and allow you to install a program using a graphical user interface. It’s an installation method that only uses the necessary and core files needed. All you have to do is double-click the package to start the setup wizard.
我们将介绍的第一种方法是使用MSI文件安装PowerShell。 MSI软件包的工作方式几乎与EXE文件相同,并且允许您使用图形用户界面安装程序。 这是一种仅使用必要的必要文件和核心文件的安装方法。 您所要做的就是双击该软件包以启动安装向导。
Note: PowerShell 7 installs and runs side-by-side with Windows PowerShell 5.1—the version that comes with Windows 10—and replaces PowerShell Core 6.x. If you need to run PowerShell 6 side-by-side with PowerShell 7, you will need to install it via the ZIP package.
注意: PowerShell 7与Windows PowerShell 5.1(Windows 10随附的版本)一起安装和运行,并取代了PowerShell Core6.x。 如果需要与PowerShell 7并行运行PowerShell 6,则需要通过ZIP软件包进行安装。
To download the package, fire up your browser and head on over the PowerShell Github releases page. Scroll down to to the Assets section, and click on the MSI package release to download it.
要下载该软件包,请启动您的浏览器,然后转到PowerShell Github版本页面 。 向下滚动到Assets(资产)部分,然后单击MSI软件包发行版以下载它。
Be sure to select the right package for your version of Windows, x64 for 64-bit and x86 for 32-bit systems. If you’re unsure which one you have, it’s easy to find out which one your system is running.
确保为您的Windows版本选择正确的软件包,对于64位系统选择x64,对于32位系统选择x86。 如果您不确定拥有哪个,则很容易找出系统正在运行哪个 。
If prompted, choose a destination for the download, and click “Save” to start the download.
如果出现提示,请选择下载目标,然后单击“保存”开始下载。
After the download completes, navigate to the folder where the file is, and double-click it to run the installation.
下载完成后,导航到文件所在的文件夹,然后双击它以运行安装。
如何使用命令安装PowerShell 7 (How to Install PowerShell 7 with a Command)
The PowerShell team has also put together a script you can invoke directly from PowerShell. It’s a one-liner cmdlet that downloads and runs the setup wizard automatically. All you have to do is paste the code snippet in and hit the Enter key.
PowerShell团队还编写了一个脚本,您可以直接从PowerShell调用该脚本 。 这是一个单行cmdlet,可自动下载并运行安装向导。 您所要做的就是将代码段粘贴到其中,然后按Enter键。
Fire up PowerShell and copy/paste the following cmdlet into the window:
启动PowerShell,然后将以下cmdlet复制/粘贴到窗口中:
iex "& { $(irm https://aka.ms/install-powershell.ps1) } -UseMSI"
Press the Enter key, and PowerShell will run the command and begin the download.
按Enter键,PowerShell将运行命令并开始下载。
经历安装程序 (Going Through the Installer)
When the setup wizard opens, click “Next” to install PowerShell 7.
安装向导打开后,单击“下一步”以安装PowerShell 7。
On the next screen, choose a destination folder, and then click “Next” when you’re ready to continue.
在下一个屏幕上,选择目标文件夹,然后在准备继续时单击“下一步”。
Next, you get to decide which optional features to enable on the install. You can enable or disable the following four options:
接下来,您将决定要在安装中启用哪些可选功能。 您可以启用或禁用以下四个选项:
Add PowerShell to Path Environment Variable: Adds PowerShell to the Windows Path environment variable and allows you to call PowerShell from any other shell or terminal.
将PowerShell添加到Path环境变量:将PowerShell添加到Windows Path环境变量,并允许您从任何其他外壳或终端调用PowerShell。
Register Windows Event Logging Manifest: Adds PowerShell to the Windows Event Logging Manifest and allows you to log events from within a PowerShell instance.
注册Windows事件日志清单:将PowerShell添加到Windows事件日志清单,并允许您从PowerShell实例中记录事件。
Enable PowerShell Remoting: Enables the ability to run commands remotely.
启用PowerShell远程处理:启用远程运行命令的功能。
Add ‘Open here’ Context Menus to Explorer: Adds an option inside the right-click context menu that opens an instance of PowerShell in the folder you click.
将“在这里打开”上下文菜单添加到资源管理器:在右键单击上下文菜单中添加一个选项,该选项可在您单击的文件夹中打开PowerShell的实例。
Click “Next” after choosing all the optional features you want.
选择所需的所有可选功能后,单击“下一步”。
Click “Install” to begin the installation. A UAC prompt will appear, asking for admin privileges to install the package. Click “Yes” to continue.
单击“安装”开始安装。 将出现一个UAC提示,要求管理员特权来安装该软件包。 单击“是”继续。
Once the setup wizard completes, click “Finish” to exit.
安装向导完成后,单击“完成”退出。
如何打开PowerShell 7 (How to Open PowerShell 7)
After the installation is complete, you can open PowerShell 7 in a few ways.
安装完成后,可以通过几种方式打开PowerShell 7。
If you selected the options “Add PowerShell to Path Environment Variable” and “Add ‘Open here’ Context Menus to Explorer,” you can type “pwsh” into Command Prompt or right-click a folder and click PowerShell 7 > Open here. However, one of the easiest methods is to search using the Start menu.
如果选择了“将PowerShell添加到路径环境变量”和“向资源管理器添加“在此处打开”上下文菜单”选项,则可以在命令提示符下键入“ pwsh”,或右键单击文件夹,然后单击PowerShell 7>在此处打开。 但是,最简单的方法之一是使用“开始”菜单进行搜索。
Press the Windows key or click the Start button, type “pwsh” into the text field, and press Enter or click “Open” when PowerShell 7 appears in the results.
按Windows键或单击“开始”按钮,在文本字段中键入“ pwsh”,然后在结果中出现PowerShell 7时按Enter或单击“打开”。
You’ll know you’re using the current and up-to-date version of PowerShell by looking for “PowerShell 7” in the window’s title bar.
通过在窗口标题栏中查找“ PowerShell 7”,您将知道您正在使用PowerShell的最新版本。
翻译自: https://www.howtogeek/663684/how-to-install-powershell-7-on-windows-10/
本文标签: 如何在 Windows Powershell
版权声明:本文标题:如何在Windows 10上安装PowerShell 7 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.freenas.com.cn/jishu/1729682145h1338946.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论