Forum Discussion
Cannot Use Newer Version of PowerShellGet in PowerShell 5.1.
- May 19, 2023
The issue was that the X86 path was before the 64-bit one when I looked at $env:PSModulePath. (There was actually another path in there pointing to my documents folder - no idea where that came from.) So I reset $env:PSModulePath, making sure the 64-bit path was first (I just removed the others), and I'm all set.
So basically because I'm running 64-bit PowerShell, it was installing commands to the 64-bit path, but the environment variable was looking in the x86 folder first. I'm sure all of this had to do with old stuff I had done with PowerShell.
I think you can refer to the about_Command_Precedence description, which describes how PowerShell determines the command to run.
You can use the prefix (-Prefix parameter of the Import-Module command) when manually importing the new PowerShellGet module, as follows:
Import-Module -Name PowerShellGet -Version "2.2.5" -Prefix now_psg
#I am using the 1.0.0.1 version of PowerShellGet for demonstration, and the 2.2.5 version of PowerShellGet is not installed on the Windows system I am using now
Get-Module PowerShellGet|fl
Name : PowerShellGet
Path : C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1
Description : PowerShell module with commands for discovering, installing, updating and publishing the PowerShell artifacts like Modules, DSC Re
sources, Role Capabilities and Scripts.
ModuleType : Script
Version : 1.0.0.1
NestedModules : {}
#Note here, the commands of this module are prefixed with now_psg ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓
ExportedFunctions : {Find-now_psgCommand, Find-now_psgDscResource, Find-now_psgModule, Find-now_psgRoleCapability...}
In this way, you can use the install-now_psgModule command to install the modules you need