From cf953c9dbdd71a956b77fdb764e14c596aa2a5a5 Mon Sep 17 00:00:00 2001 From: Keith Dahlby Date: Tue, 3 Jan 2017 17:22:21 -0600 Subject: [PATCH 1/2] Fix that module can be found by not imported? --- profile.example.ps1 | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/profile.example.ps1 b/profile.example.ps1 index d14f3769b..a17beb02b 100644 --- a/profile.example.ps1 +++ b/profile.example.ps1 @@ -1,7 +1,8 @@ # Import the posh-git module, first via installed posh-git module. # If the module isn't installed, then attempt to load it from the cloned posh-git Git repo. -if (Get-Module posh-git -ListAvailable) { - Import-Module posh-git +$poshGitModule = Get-Module posh-git -ListAvailable +if ($poshGitModule) { + $poshGitModule | Import-Module } elseif (Test-Path -LiteralPath $PSScriptRoot\posh-git.psd1) { Import-Module $PSScriptRoot\posh-git.psd1 From 0b71116bd231983749b7c56536e8bf306016c84a Mon Sep 17 00:00:00 2001 From: Keith Dahlby Date: Tue, 3 Jan 2017 22:31:07 -0600 Subject: [PATCH 2/2] Load only latest available version of the module --- profile.example.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/profile.example.ps1 b/profile.example.ps1 index a17beb02b..a71f44923 100644 --- a/profile.example.ps1 +++ b/profile.example.ps1 @@ -1,6 +1,6 @@ # Import the posh-git module, first via installed posh-git module. # If the module isn't installed, then attempt to load it from the cloned posh-git Git repo. -$poshGitModule = Get-Module posh-git -ListAvailable +$poshGitModule = Get-Module posh-git -ListAvailable | Sort-Object Version -Descending | Select-Object -First 1 if ($poshGitModule) { $poshGitModule | Import-Module }