gpt4 book ai didi

windows - 启动 PowerShell session 时出错

转载 作者:可可西里 更新时间:2023-11-01 11:18:00 29 4
gpt4 key购买 nike

我正常使用 PowerShell(正在使用 posh git,只是提一下),突然发生了一个奇怪的行为,我试图重新启动 session ,当我这样做时,我得到了很多错误,它们是:

Split-Path : The term 'Split-Path' 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 C:\Users\aymen.daoudi\Documents\WindowsPowerShell\Modules\posh-git\profile.example.ps1:1 char:16
+ Push-Location (Split-Path -Path $MyInvocation.MyCommand.Definition -P ...
+ ~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Split-Path:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException

Import-Module : The specified module '.\posh-git' was not loaded because no valid module file was found in any module directory.
At C:\Users\aymen.daoudi\Documents\WindowsPowerShell\Modules\posh-git\profile.example.ps1:4 char:1
+ Import-Module .\posh-git
+ ~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ResourceUnavailable: (.\posh-git:String) [Import-Module], FileNotFoundException
+ FullyQualifiedErrorId : Modules_ModuleNotFound,Microsoft.PowerShell.Commands.ImportModuleCommand

Enable-GitColors : The term 'Enable-GitColors' 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 C:\Users\aymen.daoudi\Documents\WindowsPowerShell\Modules\posh-git\profile.example.ps1:26 char:1
+ Enable-GitColors
+ ~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Enable-GitColors:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException

Pop-Location : The term 'Pop-Location' 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 C:\Users\aymen.daoudi\Documents\WindowsPowerShell\Modules\posh-git\profile.example.ps1:28 char:1
+ Pop-Location
+ ~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Pop-Location:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException

Start-SshAgent : The term 'Start-SshAgent' 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 C:\Users\aymen.daoudi\Documents\WindowsPowerShell\Modules\posh-git\profile.example.ps1:30 char:1
+ Start-SshAgent -Quiet
+ ~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Start-SshAgent:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException

这是一张图片:

enter image description here

我尝试重新启动 PC,但每次启动新的 PowerShell session 时仍然出现同样的问题,我注意到很多命令都不起作用,是什么导致了这个问题?我应该怎么做才能解决它?

更新

我删除了 PoshGit 添加的配置文件,当开始一个新的 session 时,我没有任何错误,但是 powershell 仍然无法识别命令,例如调用 Clear-host,抛出很多我无法识别的错误了解原因!

enter image description here

最佳答案

你是 PSModulePath 系统环境变量丢失 C:\windows\system32\WindowsPowerShell\v1.0\Modules 这是所有“系统”/PowerShell 中的内置模块。

你安装的东西(也许是 posh git?)可能把它搞砸了。将其添加到系统变量中。

在没有 PowerShell 的情况下,最简单的方法是使用 GUI,如下所述: http://www.computerhope.com/issues/ch000549.htm

关于windows - 启动 PowerShell session 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29518969/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com