oneget: Unable to import PackageManagement module 1.4.8

PS C:\Users\vmadmin> Get-PSRepository
Get-PSRepository : The 'Get-PSRepository' command was found in the module 'PowerShellGet', but the module could not be
loaded. For more information, run 'Import-Module PowerShellGet'.
At line:1 char:1
+ Get-PSRepository
+ ~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Get-PSRepository:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CouldNotAutoloadMatchingModule

PS C:\Users\vmadmin> Get-PSRepository
PackageManagement\Get-PackageSource : The term 'PackageManagement\Get-PackageSource' 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
try again.
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\2.2.5\PSModule.psm1:9539 char:31
+ ...         $packageSources = PackageManagement\Get-PackageSource @PSBoun ...
+                               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (PackageManagement\Get-PackageSource:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

New-ModuleSourceFromPackageSource : Cannot bind argument to parameter 'PackageSource' because it is null.
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\2.2.5\PSModule.psm1:9541 char:123
+ ... orEach-Object { New-ModuleSourceFromPackageSource -PackageSource $_ }
+                                                                      ~~
    + CategoryInfo          : InvalidData: (:) [New-ModuleSourceFromPackageSource], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,New-ModuleSourceFromPackageSource

PS C:\Users\vmadmin>

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Reactions: 2
  • Comments: 17

Most upvoted comments

Okay, the issue with 1.4.8 was due to the strong name signing process in our pipeline. For some reason the strong name signature was showing as valid on Microsoft machines (probably a cert that’s by default on our machines), but not on other machines. There’s a fix for this and https://www.powershellgallery.com/packages/PackageManagement/1.4.8.1 should have a valid strong name signature for everyone now 😄

Note: version 1.4.8.1 is unlisted right now, but still accessible if you find/install that exact version. I’ll list again after the weekend.

I’m experiencing the same problem on many of our Windows Server 2016 servers that automatically updated to v1.4.8 of the PackageManagement module.

image

image

And here’s the output of running the commands you asked @awickham10 to run above @anamnavi

PowerShell_transcript.20220628163306.txt

Thanks for unlisting PackageManagement v1.4.8 from the PowerShell Gallery so quickly team! 👍

Since PackageManagement v1.4.8 breaks the ability to use PowerShell to uninstall packages, I fixed up our servers by manually deleting the 1.4.8 module. You can check $env:PSModulePath to see where the module might be installed on your machine. For me it was located at C:\Program Files\WindowsPowerShell\Modules\PackageManagement\1.4.8, so I just deleted that directory and it got our servers back into a good state.

@alerickson can you take a look?

I’m having issues as well. Can’t import PackageManagement or PowerShellGet modules. PowerShell 5.1.17763.2931.

PS C:\> Import-Module PackageManagement
Import-Module: Could not load file or assembly 'Microsoft.PackageManagement, Version=3.0.0.1, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. Strong name validation failed. (Exception from HRESULT: 0x8013141A) At C:\Program Files\WindowsPowerShell\Modules\packagemanagement\1.4.8\PackageManagement.psm1:38 char:17 + $OneGetModule = Import-Module -name $OneGetModulePath -PassThru

I was able to revert to 1.4.7 and it resolved the issue for the server.