Question:
I want to install posh-git on laptop but when I try installing w/command “PowerShellGet\Install-Module posh-git -Scope CurrentUser -AllowPrerelease -Force” I get error:
1 2 3 4 5 6 7 8 9 |
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 |
Reading the errata at the github site I see it says I need to update my PowerShellGet module w/ “Install-Module PowerShellGet -S
cope CurrentUser -Force -AllowClobber” But this gives error :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
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 |
I have googled and tried several ways to update PowerShellGet from v1.0.0.1 which shows on my laptop, all to no avail. Any advice on how to rectify this would be much appreciated.
Answer:
The error is specific. You are using a parameter / switch that does not exist by default for modules.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# 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 |
As per the docs:
Prerelease Versioning Added to PowerShellGet and PowerShell Gallery
Developers have to add this or it’s not available for use.
Publishers simply add the prerelease string (ie. the part that comes
after “2.0.0”) in the metadata, and the version will be considered
prerelease. For example:
1 2 3 4 5 6 7 8 9 10 |
@{ ModuleVersion = '2.0.0' #--- PrivateData = @{ PSData = @{ Prerelease = '-alpha' } } } |
This…
1 2 |
PowerShellGet\Install-Module |
… is also not the common way (that I am aware of) regarding how you install a module. You should only need the Install-Module cmdlet, PowerShell already knows the module it comes from and autoloads that, if not already loaded.
Try this…
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
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 |