安装posh-git遇到问题

5
我想在笔记本电脑上安装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

在 GitHub 网站上阅读勘误后,我发现需要使用“Install-Module PowerShellGet -Scope 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

我已经尝试了多种方法来更新PowerShellGet,但都没有成功。目前我使用的是v1.0.0.1版本。请问有什么建议或方法可以解决这个问题?非常感谢。

1个回答

3
错误是具体的。您正在使用默认情况下模块不存在的参数/开关。
# get function / cmdlet details
(Get-Command -Name Install-Module).Parameters.Keys
<#
Name
InputObject
MinimumVersion
MaximumVersion
RequiredVersion
Repository
Credential
Scope
Proxy
ProxyCredential
AllowClobber
SkipPublisherCheck
Force
Verbose
Debug
ErrorAction
WarningAction
InformationAction
ErrorVariable
WarningVariable
InformationVariable
OutVariable
OutBuffer
PipelineVariable
WhatIf
Confirm
#>
Get-help -Name Install-Module -Examples
Get-help -Name Install-Module -Full
Get-help -Name Install-Module -Online

根据文档:

PowerShellGet和PowerShell Gallery中添加了预发布版本控制

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

发布者只需在元数据中添加预发布字符串(即“2.0.0”之后的部分),该版本即被视为预发布版。例如:

@{
   ModuleVersion = '2.0.0'
   #---
      PrivateData = @{
         PSData = @{
            Prerelease = '-alpha'
      }
   }
}

这个...

PowerShellGet\Install-Module

我也不知道这是常规的安装模块方式。你只需要使用Install-Module命令,PowerShell已经知道该模块来自哪里,并在需要时自动加载,如果尚未加载。

试试这个...

Find-Module -Name posh-git

Version    Name       Repository           Description
-------    ----       ----------           -----------
0.7.3      posh-git   PSGallery            Provides prompt ...



Find-Module -Name posh-git | 
Save-Module -Path "$env:USERPROFILE\Documents\WindowsPowerShell\Modules" # -WhatIf

What if: Performing the operation "Save Package" on target "'posh-git' to location 'C:\Users\Daniel\Documents\WindowsPowerShell\Modules'".


Install-Module -Name posh-git -Scope CurrentUser -Force

谢谢你的回答。我现在已经使用了chocalety来安装posh-git,但将来会尝试你的解决方案。 - Alan
安装模块部分对我很有帮助。 - Pepe Alvarez

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接