导读 PowerShell Core 6.2 GA 已发布,PowerShell Core 是 PowerShell 的开源版本,适用于 Linux,macOS 和 Windows。

有关 PowerShell Core 6.2 的安装信息,请查看安装文档("https://aka.ms/install-powershell")。

另外,PowerShell Core 与 Windows PowerShell 可同时运行,两者能够彼此独立使用。这就意味着我们可以继续将 Windows PowerShell 用于现有脚本,同时使用 PowerShell Core 实现新的自动化或探索其新功能。

更新内容

自 6.1.0 发布(2018 年 9 月)以来,开发团队已经对 6.2 版本进行了 560 次更改,具体的变更详情请点此查看。PowerShell Core 6.2 版本主要侧重于性能改进、错误修复以及可提升效率的较小 命令行(cmdlet)/语言增强功能。

实验性功能

未找到命令时的建议

Enable-ExperimentalFeature -Name PSCommandNotFoundSuggestion

当用户输入命令行时,如果出现拼写错误的情况,此功能将使用模糊匹配来查找使用者可能打算输入的命令,并提供建议。

PS> Get-Commnd
Get-Commnd : The term 'Get-Commnd' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ Get-Commnd
+ ~~~~~~~~~~
+ CategoryInfo          : ObjectNotFound: (Get-Commnd:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
 
 
Suggestion [4,General]: The most similar commands are: Get-Command, Get-Content, Get-Job, Get-Module, Get-Event, Get-Host, Get-Member, Get-Item, Set-Co

上面的这个例子中,使用者拼写错了

Get-Command

并且模糊地匹配了很多最可能、以及最不可能的建议。

隐式远程批处理
Enable-ExperimentalFeature -Name PSImplicitRemotingBatching

在管道中使用隐式远程处理时,PowerShell 会独立处理管道中的每个命令。这导致在
管道的执行过程中反复地在客户端和目标系统之间对对象进行序列化和反序列化。

若应用此特性,PowerShell 会分析管道并确定命令是否可以安全运行,或者命令是否存在于目标系统上,并且能够远程执行整个管道,最后只将结果序列化和反序列化回客户端。

原文来自:https://www.oschina.net/news/105620/powershell-core-6-2-released

本文地址:https://www.linuxprobe.com/powershell-core-release.html编辑:黑曜羽,审核员:逄增宝

Linux命令大全:https://www.linuxcool.com/

Linux系统大全:https://www.linuxdown.com/

红帽认证RHCE考试心得:https://www.rhce.net/