我想在笔记本电脑上安装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 -S”更新我的PowerShellGet模块。 应对CurrentUser -Force -AllowClobber“,但这会导致错误:
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
我已经用Google搜索并尝试了几种方法来从我的笔记本电脑上显示的v1.0.0.1更新PowerShellGet,但无济于事。任何有关如何纠正这一问题的建议将不胜感激。
答案 0 :(得分:1)
该错误是特定的。您正在使用默认情况下模块不存在的参数/开关。
# 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
根据文档:
Prerelease Versioning Added to PowerShellGet and PowerShell Gallery
开发人员必须添加它,否则将无法使用。
发布者只需添加预发布字符串(即附带的部分) 在元数据中的“ 2.0.0”之后),该版本将被视为 预发行。例如:
@{
ModuleVersion = '2.0.0'
#---
PrivateData = @{
PSData = @{
Prerelease = '-alpha'
}
}
}
这个...
PowerShellGet\Install-Module
...也不是安装模块的常用方法(我知道)。您只需要Install-Module cmdlet,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