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 會分析管道並確定命令是否可以安全運行,或者命令是否存在於目標系統上,並且能夠遠程執行整個管道,最后只將結果序列化和反序列化回客戶端。