I am trying to install PackageManagement in Powershell 7.4.4.
I’ve enabled Tls2, Set PSGallery to trusted, and set my execution policy to RemoteSigned (Scope: LocalMachine)
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope LocalMachine
Set-PSReposiotory -Name PSGallery -InstallationPolicy Trusted
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor [System.Net.SecurityProtocolType]::Tls12
I’m now trying to install PackageManagement and PowerShellGet with the following:
Install-Module -Name PackageManagement -Repository PSGallery -Force
Install-Module -Name PowerShellGet -Repository PSGallery -Force -AllowClobber
But when I run the PackageManagement install, I get an error:
WARNING: The version '1.4.8.1' of module 'PackageManagement' is currently in use. Retry the operation after closing the applications.
Get-Module packagemanagement -ListAvailable
returns this:
Directory: C:program filespowershell7Modules
ModuleType Version PreRelease Name PSEdition ExportedCommands
---------- ------- ---------- ---- --------- ----------------
Script 1.4.8.1 PackageManagement Desk {Find-Package, Get-Package, Get-PackageProv…
So Pwsh is using the PackageManagement 1.4.8.1 script located in C:program filespowershell7Modules
.
But when I run Get-InstalledModule
, only PowerShellGet (v2.2.5) shows up, without PackageManagement
. At least I got the required PowerShellGet version installed, but unfortunately the way PackageManagement is being loaded seems to be defective. Currently Install-Module
is broken.
Example: When I run Install-Module [AnyModuleName]
, the module doesn’t install. I have to add the -Force
switch for the module to actually install.
I have a feeling that I need to remove or sidestep the PackageManagement version located in C:program filespowershell7Modules
, and actually INSTALL the PackageManagement
module. It should appear when I run Get-InstalledModule
.
Regarding the NuGet provider, the correct assemblies are located at C:Program FilesPackageManagementProviderAssembliesnuget2.8.5.208Microsoft.PackageManagement.NuGetProvider.dll
Powershell also states:
You can also install the NuGet provider by running ‘Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force’.
So I tried that command: Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force
But Pwsh spits out this error:
Install-PackageProvider: No match was found for the specified search criteria for the provider 'NuGet'. The package provider requires 'PackageManagement' and 'Provider' tags. Please check if the specified package has the tags.
Lastly, here is my PSModulePath environment variable:
I am at my wits end here. I’ve been trying to solve this problem for the last four hours with no success.
I would REALLY appreciate any help getting this issue resolved.
Thanks for any assistance.