powershellposh-git

Trouble installing posh-git


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:

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 :

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.


Solution

  • The error is specific. You are using a parameter / switch that does not exist by default for modules.

    # 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:

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

    This...

    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...

    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