The term 'Install-Module' is not recognized as the name of a cmdlet
Asked Answered
Q

2

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?

Quadrature answered 23/4, 2015 at 16:2 Comment(0)
T
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!

Trondheim answered 23/4, 2015 at 16:4 Comment(6)
The names PSGet and poshgit are so close I read them as the same product. WoopsQuadrature
The question was about Install-Module being unrecognized commandletTrifocals
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)Trifocals
@Trifocals 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.Trondheim
@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).Trifocals
make sure you run the powershell or powershell ISE as adminFaustofaustus
H
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.

Horsemint answered 22/4, 2021 at 20:31 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.