23

I am following the directions to install poshgit. In doing so I ran:

Install-Module posh-git

Error:

The term 'Install-Module' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and t ry again.

I ran $PSVersionTable.PSVersion: result = 2.0.-1.-1

Is Install-Module an addon? How can I run this command?

Abhijit
  • 1,153
  • 2
  • 16
  • 32
P.Brian.Mackey
  • 43,228
  • 68
  • 238
  • 348

2 Answers2

9

Do you have PsGet installed? That's the Installing via PsGet section.

The section after that is the manual instructions:

  1. Verify you have PowerShell 2.0 or better with $PSVersionTable.PSVersion

  2. Verify execution of scripts is allowed with Get-ExecutionPolicy (should be RemoteSigned or Unrestricted). If scripts are not enabled, run PowerShell as Administrator and call Set-ExecutionPolicy RemoteSigned -Scope CurrentUser -Confirm.

  3. Verify that git can be run from PowerShell. If the command is not found, you will need to add a git alias or add %ProgramFiles(x86)%\Git\cmd (or %ProgramFiles%\Git\cmd if you're still on 32-bit) to your PATH environment variable.

  4. Clone the posh-git repository to your local machine.

  5. From the posh-git repository directory, run .\install.ps1.

  6. Enjoy!

Etan Reisner
  • 77,877
  • 8
  • 106
  • 148
  • 1
    The names PSGet and poshgit are so close I read them as the same product. Woops – P.Brian.Mackey Apr 23 '15 at 16:09
  • 3
    The question was about Install-Module being unrecognized commandlet – Abhijit Aug 09 '16 at 14:56
  • 2
    install-module is part of PowerShellGet module which is available from the PowerShell Gallery. Installing from PowerShell Gallery requires the latest version of the PoweShellGet module which is available in - Windows 10, in Windows Management Frameowork 5.0, or in the MSI-based installer(for Powershell 3 and 4). Since I've got PS4, I went and installed via the MSI (PackageManagement PowerShell Modules Preview - March 2016) – Abhijit Aug 09 '16 at 15:32
  • 1
    @Abhijit Yes, which is why the first part of my answer was "Do you have `PsGet` installed?" as that would be why `Import-Module` might not be available. Information about Windows 10 is useful but post-dates this answer by at least three months. – Etan Reisner Aug 10 '16 at 12:38
  • @EtanReisner My apologies. I reached this post when I had problem getting Install-Module to run and I could resolve that by installing PackageManagement PowerShell Modules MSI package (I'm still on PS 4). I wasn't aware of PsGet (as against PowerShellGet from Microsoft). – Abhijit Aug 10 '16 at 15:44
  • make sure you run the powershell or powershell ISE as admin – Chris Wood Oct 06 '16 at 16:54
1

I had the same problem but with $PSVersionTable.PSVersion = 4.0. Apparently Install-Module is part of PS v5.

I downloaded PS 5 from here: https://www.microsoft.com/en-us/download/details.aspx?id=54616

I'm still on Win 8.1 x64 so I chose Win8.1AndW2K12R2-KB3191564-x64.msu but pick the file appropriate for your environment.

Reboot, start PS and retry the Install-Module command.

Jeff Mergler
  • 1,384
  • 20
  • 27