安装 posh-git 时遇到问题

Ala*_*lan 5 powershell posh-git

我想在笔记本电脑上安装 posh-git,但是当我尝试使用命令“PowerShellGet\Install-Module posh-git -Scope CurrentUser -AllowPrerelease -Force”安装时,出现错误:

Install-Module : A parameter cannot be found that matches parameter name
'AllowPrerelease'.
At line:1 char:58
+ ... et\Install-Module posh-git -Scope CurrentUser -AllowPrerelease -Force
+                                                   ~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [Install-Module], Paramet
   erBindingException
    + FullyQualifiedErrorId : NamedParameterNotFound,Install-Module
Run Code Online (Sandbox Code Playgroud)

阅读 github 站点上的勘误表,我看到它说我需要使用“Install-Module PowerShellGet -S cop CurrentUser -Force -AllowClobber”更新我的 PowerShellGet 模块,但这会产生错误:

PackageManagement\Install-Package : The module 'PackageManagement' cannot be
installed or updated because the authenticode signature of the file
'PackageManagement.cat' is not valid.
At C:\Program
Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1:1809
char:21
+ ...          $null = PackageManagement\Install-Package @PSBoundParameters
+                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (Microsoft.Power....InstallP
   ackage:InstallPackage) [Install-Package], Exception
    + FullyQualifiedErrorId : InvalidAuthenticodeSignature,ValidateAndGet-Au
   thenticodeSignature,Microsoft.PowerShell.PackageManagement.Cmdlets.Insta
  llPackage
Run Code Online (Sandbox Code Playgroud)

我用谷歌搜索并尝试了多种方法来更新我的笔记本电脑上显示的 v1.0.0.1 PowerShellGet,但都无济于事。任何有关如何纠正此问题的建议将不胜感激。

pos*_*ote 3

错误是具体的。您正在使用模块默认情况下不存在的参数/开关。

\n\n
# get function / cmdlet details\n(Get-Command -Name Install-Module).Parameters.Keys\n<#\nName\nInputObject\nMinimumVersion\nMaximumVersion\nRequiredVersion\nRepository\nCredential\nScope\nProxy\nProxyCredential\nAllowClobber\nSkipPublisherCheck\nForce\nVerbose\nDebug\nErrorAction\nWarningAction\nInformationAction\nErrorVariable\nWarningVariable\nInformationVariable\nOutVariable\nOutBuffer\nPipelineVariable\nWhatIf\nConfirm\n#>\nGet-help -Name Install-Module -Examples\nGet-help -Name Install-Module -Full\nGet-help -Name Install-Module -Online\n
Run Code Online (Sandbox Code Playgroud)\n\n

根据文档:

\n\n

PowerShellGet 和 PowerShell 库中添加了预发行版本控制

\n\n

开发人员必须添加它,否则它无法使用。

\n\n
\n

发布者只需在元数据中添加预发布字符串(即 \xe2\x80\x9c2.0.0\xe2\x80\x9d 之后的部分),该版本将被视为预发布。例如:

\n
\n\n
@{\n   ModuleVersion = \'2.0.0\'\n   #---\n      PrivateData = @{\n         PSData = @{\n            Prerelease = \'-alpha\'\n      }\n   }\n}\n
Run Code Online (Sandbox Code Playgroud)\n\n

这...

\n\n
PowerShellGet\\Install-Module\n
Run Code Online (Sandbox Code Playgroud)\n\n

\xe2\x80\xa6 也不是关于如何安装模块的常用方法(据我所知)。您应该只需要 Install-Module cmdlet,PowerShell 已经知道它来自的模块并自动加载该模块(如果尚未加载)。

\n\n

尝试这个...

\n\n
Find-Module -Name posh-git\n\nVersion    Name       Repository           Description\n-------    ----       ----------           -----------\n0.7.3      posh-git   PSGallery            Provides prompt ...\n\n\n\nFind-Module -Name posh-git | \nSave-Module -Path "$env:USERPROFILE\\Documents\\WindowsPowerShell\\Modules" # -WhatIf\n\nWhat if: Performing the operation "Save Package" on target "\'posh-git\' to location \'C:\\Users\\Daniel\\Documents\\WindowsPowerShell\\Modules\'".\n\n\nInstall-Module -Name posh-git -Scope CurrentUser -Force\n
Run Code Online (Sandbox Code Playgroud)\n