1

I've always used Phil Haack's method of installing Posh-Git, with the following PowerShell commands:

(new-object Net.WebClient).DownloadString("http://psget.net/GetPsGet.ps1") | iex
install-module posh-git

The first line installs PsGet, and the second Post Git. I've also just tried install-module posh-git, having installed PsGet.

What happens is that the Post-Git prompt shows in the same PS Window I installed it in, but when I close that window and open another, Post-Git seems gone again.

This is a new machine, with a new Windows 10 Pro. Posh-Git worked on my old one, also with Windows 10 Pro, the only difference I know is the new one is SSD, and that shouldn't affect any of this.

ProfK
  • 49,207
  • 121
  • 399
  • 775

2 Answers2

2

It seems that you are confusing Installing a module (Install-Module) with loading (importing) a module (Import-Module).

To import your module on every start of PowerShell:

...either create a prepared shortcut with a command line like %windir%\system32\WindowsPowerShell\v1.0\powershell.exe -noexit -Command Import-Module posh-git

...or use PowerShell profiles.

I'd prefer the latter if you plan to import several modules (maybe based on special conditions). Please keep in mind anyway, that loading a heavy profile will affect your PowerShells startup performance.

Clijsters
  • 4,031
  • 1
  • 27
  • 37
  • If I'm confusing one thing with another, then why did that one thing work on my home laptop, and my first work laptop (3 weeks ago)? I'm sure the Posh-Git installer is supposed to, or used to, add that to the profile. – ProfK May 18 '17 at 14:02
  • But thank you, a manual entry to my profile to load the posh-git module, the first time I've ever needed it, worked fine. – ProfK May 18 '17 at 14:09
  • I don't know how you installed it on your home laptop. I could imagine you used a GUI installer or such a thing. You didn't write that its just 3 weeks ago. Sometimes one wants to reinstall software installed years ago and just uses another way or another manual, you know? Same on my Win7 home machine. Not sure exactly but I think a GitHub installer installed it for me.... – Clijsters May 18 '17 at 14:43
1

I found this on GitHub useful, by @rkeithhill:

No worries. Once you've imported it, you can run the Add-PoshGitToProfile -AllHosts so that the next time you start PowerShell, posh-git will automatically get imported.

Maytham Fahmi
  • 31,138
  • 14
  • 118
  • 137