Open vvkjndl opened 2 years ago
Please let me know if any other details may be needed for reproducing or troubleshooting.
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.
@alerickson can you take a look?
Question for both of you, @vvkjndl and @awickham10, is this only when you explicitly run Import-Module
? Do you have the same issue after starting a fresh session?
Same issue persist in all prospective fresh sessions as long as 1.4.8 version of PackageManagement exists on system.
@vvkjndl I found this issue online regarding the CouldNotAutoLoadMatchingModule error.
Can you set your execution policy to see if it's able to import?
Other info that would be helpful for debugging:
The output of gmo powershellget, packagemanagement -listavailable
Sharing the contents of the nuget.config file
Get-Content "$env:AppData\Roaming\NuGet\nuget.config" -raw
(If there's any private information here feel free to redact)
@awickham10 can you run the following and share output: run WindowsPowerShell in admin mode
$PSVersionTable
Get-PSRepository
Install-Module "PackageManagement" -RequiredVersion "1.4.8" -Repository "PSGallery"
Import-Module "PackageManagement" -RequiredVersion "1.4.8"
Get-PSRepository
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.
And here's the output of running the commands you asked @awickham10 to run above @anamnavi
Considering this is a pretty debilitating bug (e.g. can't install, update, or remove modules), it may be worth trying to unlist v1.4.8 from the Gallery, or mark it as a preview, to prevent others from updating to it until this is resolved.
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.
I'm debugging right now and can't figure out what exactly is going on... I verified the strong name signature using sn.exe and the files appear to be valid.
@deadlydog can you run get-executionpolicy
so I can have a little more context to your environment?
Our Execution Policy on that particular server is RemoteSigned
.
I did a quick search in all our PowerShell modules for Microsoft.PackageManagement.dll
, and the PackageManagement module versions are the only ones that contain it, so nothing else should be loading a different version into memory. Perhaps it's one of the Microsoft.PackageManagement.dll's dependencies that can't be loaded? Maybe a different version of the dependency is already in memory so it can't load the required version?
My execution policy is Unrestricted.
I have several PowerShell scripts in my infrastructure that automatically updates the module to latest version.
Here's a workaround that I have applied on my servers:
C:\Program Files\WindowsPowerShell\Modules\PackageManagement\
).Piling on that I had this same issue. Windows Server 2016. Tried even a brand new Windows install and manually installing the packages. Same exact errors messages and lack of Exported Commands either with explicit or implicit imports.
@vvkjndl I found this issue online regarding the CouldNotAutoLoadMatchingModule error. Can you set your execution policy to see if it's able to import?
Other info that would be helpful for debugging:
* The output of `gmo powershellget, packagemanagement -listavailable` * Sharing the contents of the nuget.config file `Get-Content "$env:AppData\Roaming\NuGet\nuget.config" -raw`
(If there's any private information here feel free to redact)
@alerickson Information you asked for:
PS C:\Users\vmadmin> Get-Content -Path C:\Users\vmadmin\AppData\Roaming\NuGet\nuget.config -Raw
<?xml version="1.0"?>
<configuration>
<packageSources>
</packageSources>
</configuration>
PS C:\Users\vmadmin> gmo powershellget, packagemanagement -listavailable
Directory: C:\Program Files\WindowsPowerShell\Modules
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Script 1.4.7 PackageManagement {Find-Package, Get-Package, Get-PackageProvider, Get-PackageSource...}
Binary 1.0.0.1 PackageManagement {Find-Package, Get-Package, Get-PackageProvider, Get-PackageSource...}
Script 2.2.5 PowerShellGet {Find-Command, Find-DSCResource, Find-Module, Find-RoleCapability...}
Script 1.0.0.1 PowerShellGet {Install-Module, Find-Module, Save-Module, Update-Module...}
PS C:\Users\vmadmin> Get-ExecutionPolicy
Unrestricted
PS C:\Users\vmadmin>
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 :smile:
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.
Thanks for getting this resolved so quickly @alerickson! I provisioned several new servers yesterday, which pull the latest PackageManagement, and did not have any problems.