Solved: ‘Answering Yes to “You have an older version of PackageManagement known to cause issues with the PowerShell extension. Would you like to update PackageManagement (You will need to restart the PowerShell extension after)?” hung my Visual Studio Code.…’
Posted by jpluimers on 2021/10/04
From a while back: [Archive.is] Jeroen Wiert Pluimers on Twitter: ‘Answering Yes to “You have an older version of PackageManagement known to cause issues with the PowerShell extension. Would you like to update PackageManagement (You will need to restart the PowerShell extension after)?” hung my Visual Studio Code.… ‘
After clicking “Yes”, the the only thing visible was this notification that had an ever running “progress bar”:
Notifications – Powershell – Source: Powershell (Extension)
The first part of the solution was relatively simple: restart Visual Studio code, then the original notification showed, and after clicking “Yes”, the “Panel” (you can toggle it with Ctrl+J) showed the “Terminal” output (yes, I was working on [Wayback/Archive.is] PowerShell script for sending Wake-on-LAN magic packets to given machine hardware MAC address, more about that later):
PowerShell Terminal – NuGet provider is required to continue
=====> PowerShell Integrated Console v2021.9.0 <===== PS C:\Users\jeroenp\Versioned\gist.github.com\344ed287b784048349769a334f116b46> powershell.exe -NoLogo -NoProfile -Commanand '[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; Install-Module -Name PackageManagenement -Force -MinimumVersion 1.4.6 -Scope CurrentUser -AllowClobber -Repository PSGallery' NuGet provider is required to continue PowerShellGet requires NuGet provider version '2.8.5.201' or newer to interact with NuGet-based repositories. The NuGet p provider must be available in 'C:\Program Files\PackageManagement\ProviderAssemblies' or 'C:\Users\jeroenp\AppData\Local\PackageManagement\ProviderAssemblies'. You can also install the NuGet provider by runningng 'Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force'. Do you want PowerShellGet to install and import the NuGet provider now? [Y] Yes [N] No [S] Suspend [?] Help (default is "Y"):
Choosing the default “Y” quickly solved it:
PackageManagement updated, If you already had PackageManagement loaded in your session, please restart the PowerShell extension.
This was on a Windows 10 system having stock PowerShell 5.1:
C:\>PowerShell $PSVersionTable.PSVersion.ToString() 5.1.19041.1237
I still did some more research, because usually things like above will break systems in the future.
Doing a [Wayback] “You have an older version of PackageManagement known to cause issues with the PowerShell extension. Would you like to update PackageManagement (You will need to restart the PowerShell extension after)?” – Google Search showed me I was not alone and that various issues can lead to problems installing PackageManagement
.
The search gave these important results that got me going; the third eventually leads to the first as they are related:
- [Wayback/Archive.is] “You have an older version of PackageManagement…” Prompts Repeatedly · Issue #2824 · PowerShell/vscode-powershell
- [Wayback] powershell – VS Code always prompts: “older version of PackageManagement known to cause issues” – Stack Overflow
- [Archive.is] Marc D Anderson on Twitter: ‘Anyone else getting this continually in @code with #PowerShell? “You have an older version of PackageManagement known to cause issues with the PowerShell extension. Would you like to update PackageManagement (You will need to restart the PowerShell extension after)?” ‘ / Twitter
- [Wayback] Fixing issues downloading NuGet (TLS Issue in PowerShell) | Navarro Tech
So I learned a few things, first about the pieces involved:
- [Wayback] Bootstrapping NuGet – PowerShell | Microsoft Docs
NuGet.exe
is not included in the latest NuGet provider. For publish operations of either a module or script, PowerShellGet requires the binary executableNuGet.exe.
Only the NuGet provider is required for all other operations, includingfind
,install
,save
, anduninstall
. PowerShellGet includes logic to handle either a combined bootstrap of the NuGet provider andNuGet.exe,
or bootstrap of only the NuGet provider. In either case, only a single prompt message should occur. If the machine is not connected to the Internet, the user or an administrator must copy a trusted instance of the NuGet provider and/or theNuGet.exe
file to the disconnected machine.Note
Starting with version 6, the NuGet provider is included in the installation of PowerShell.
So upgrading to PowerShell version 6 or newer would have skipped this question.
- [Wayback/Archive.is]
PackageManagement
(which itself is a package):
PackageManagement (a.k.a. OneGet) is a new way to discover and install software packages from around the web.
It is a manager or multiplexor of existing package managers (also called package providers) that unifies Windows package management with a single Windows PowerShell interface. With PackageManagement, you can do the following.- Manage a list of software repositories in which packages can be searched, acquired and installed
- Discover software packages
- Seamlessly install, uninstall, and inventory packages from one or more software repositories
As of writing, the current
PackageManagement
version is [Wayback] 1.4.7 from 2020, but the minimum version required is version [Wayback] 1.4.6 from 2019.
The second thing I learned was about the bits that can go wrong. Basically they fall into three categories:
- TLS support (there have been numerous issues on Windows moving from TLS 1.0 via 1.1 to 1.2, see for instance my blog post
WinHTTP
Cipher restrictions toTLSv1.2
does not work on Windows7, Server 2008 R2 and Server 2012…) is hard, hence the[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12;
bit in the-Command
above.This is explained/confirmed by at least these links:- [Wayback] Powershell in a Post-TLS1.1 World | rnelson0
After some searching, I stumbled on a solution on the Microsoft Community site [Wayback]. The issue is that PowerShell 5.1 defaults to only enabling SSL3 and TLS 1.0 for secure HTTP connections. You have probably noticed a lot of recent warnings on various websites about services removing support for TLS 1.0 and 1.1, and SSL3 has been disabled for many for years. Microsoft is no slacker here, and go.microsoft.com has dropped support for SSL3 and TLS 1.0 (probably TLS 1.1, too, but I didn’t check). Thus the Provider list at the URL cannot be accessed and the NuGet install fails.
PS C:\ProgramData\Documents> [Net.ServicePointManager]::SecurityProtocol Ssl3, Tls
You can fix this by specifying
Tls12
as the SecurityProtocol, but it only persists in this session, for this user. - [Wayback] Powershell: How do I install the Nuget provider for PowerShell on a unconnected machine so I can install a nuget package from the PS command line? – Stack Overflow (thanks [Wayback] Luis Gouveia and [Wayback] Piotr Kula!):
Although I’ve tried all the previous answers, only the following one worked out:
- Open Powershell (as Admin)
- Run:
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
- Run:
Install-PackageProvider -Name NuGet
The author is Niels Weistra: Microsoft Forum
…
For some reason Microsoft have not updated that repository to a better SSL version hence I was getting errors before using command 2 to allow downgraded TLS versions.
And thanks [Wayback] Niels for the [Wayback] Trying to install program using Powershell and getting this error – Microsoft Community reply:
Well, I had the same problem. Set my Powershell to TLS 1.2 and it worked for me.
To test this :
1. Open Powershell (As Admin)
2.
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
3. Try it again!
The solution mentioned above is a workaround, to solve your issue permanently
1. Open Powershell and check for supported protocols by using
[Net.ServicePointManager]::SecurityProtocol
2. Run the following 2 cmdlets to set .NET Framework strong cryptography registry keys:
- Set strong cryptography on 64 bit .Net Framework (version 4 and above)
Set-ItemProperty -Path 'HKLM:\SOFTWARE\Wow6432Node\Microsoft\.NetFramework\v4.0.30319' -Name 'SchUseStrongCrypto' -Value '1' -Type DWord
set strong cryptography on 32 bit .Net Framework (version 4 and above)Set-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\.NetFramework\v4.0.30319' -Name 'SchUseStrongCrypto' -Value '1' -Type DWord
3. Restart Powershell and check again for supported protocol by using
[Net.ServicePointManager]::SecurityProtocol
- [Wayback] Fixing issues downloading NuGet (TLS Issue in PowerShell) | Navarro Tech (referring to the above Stack Overflow post)
The good people at [Wayback] StackOverflow came through with the fix:
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
After doing so (running as admin, of course) all was right with the world.
- [Wayback] Powershell in a Post-TLS1.1 World | rnelson0
- PowerShell trying to install packages in the wrong place, for instance on your OneDrive path. This happened for [Wayback/Archive.is] “You have an older version of PackageManagement…” Prompts Repeatedly · Issue #2824 · PowerShell/vscode-powershell:
No idea why it would be installing to
D:\OneDrive\Documents\WindowsPowerShell\Modules
…
I suspect theGetFolderPath()
result is because OneDrive has frustratingly mangled your settings.The way to solve this in your case is toSave-Module PackageManagement -MinimumVersion 1.4.7 -LiteralPath 'C:\Users\mdent\Documents\WindowsPowerShell\Modules\
(may need to massage that command a bit). - Visual Studio Code or other processes that use PowerShell can keep parts of the files to be updated locked. This happened for instance with [Wayback/Archive.is] Powershell: Unable to update PowerShellGet , error: The version ‘1.4.7’ of module ‘PackageManagement’ is currently in use – Stack Overflow
This is what I learned as well:
PackageManagement
installation is important, but also tricky because of the many Windows and PowerShell versions, and the varying client and server TLS support:- Listing available PackageManagement (
Get-Module
is often abbreviated togmo
and-ListAvailable
to-List
; sometimesPackageManagement
is in front of-ListAvailable
):
PS C:\> Get-Module -ListAvailable PackageManagement Directory: C:\Program Files\WindowsPowerShell\Modules ModuleType Version Name ExportedCommands ---------- ------- ---- ---------------- Binary 1.0.0.1 PackageManagement {Find-Package, Get-Package, Get-PackageProvider, Get-Packa...
- [Wayback] Update PowerShellGet and PackageManagement – Thomas Maurer
PowerShellGet
is a PowerShell module with commands for discovering, installing, updating and publishing the PowerShell artifacts like Modules, DSC Resources, Role Capabilities and Scripts. For example you usePowerShellGet
to install the Azure PowerShell module, or other modules.PowerShellGet
module is also integrated with thePackageManagement
module as a provider, users can also use the PowerShellPackageManagement
cmdlets for discovering, installing and updating the PowerShell artifacts like Modules and Scripts.…
If you use
Update-Module
, it will automatically loadPowerShellGet
andPackageManagement
and list them as loaded PowerShell modules. Of course you can also useGet-Module -ListAvailable
.…
Two quick tips, first of, you will need to set the execution policy to
RemoteSigned
to allow the new module to run. Secondly in some cases you will need to use the-AllowClobber
parameter to install the updated version of the module. - One can go the manual way of installing as per [Wayback] How to upgrade PowerShell version from 2.0 to 3.0 – Stack Overflow
–jeroen
Leave a Reply