文章

解决windows11下powershell无法执行pwsh命令

出现如下情况一般都是powershell版本有点低了:

pwsh : 无法将“pwsh”项识别为 cmdlet、函数、脚本文件或可运行程序的名称。请检查名称的拼写,如果包括路径,请确保路径正确
,然后再试一次。
所在位置 行:1 字符: 1
+ pwsh -v
+ ~~~~
    + CategoryInfo          : ObjectNotFound: (pwsh:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

执行以下命令解决:

winget search Microsoft.PowerShell

输出

Name               Id                           Version   Source
-----------------------------------------------------------------
PowerShell         Microsoft.PowerShell         7.4.2.0   winget
PowerShell Preview Microsoft.PowerShell.Preview 7.5.0.2   winget

更新最新的posershell

winget install --id Microsoft.Powershell --source winget

然后关闭终端重新打开,就可以执行pwsh 命令了

许可协议:  CC BY 4.0