Vscode-powershell: PackageManagement Module Update Problem

Created on 12 Jun 2020  路  12Comments  路  Source: PowerShell/vscode-powershell

Issue Description

When I start Powershell Extension, VSCode warns me about a conflict with the current version of PackageManagement module and recommend me to update it. When I run command :

powershell.exe -NoLogo -NoProfile -Command 'Install-Module -Name PackageManagement -Force -MinimumVersion 1.4.6 -Scope CurrentUser -AllowClobber

It gives error :

WARNING: Unable to resolve package source 'https://www.powershellgallery.com/api/v2/'.
PackageManagement\Install-Package : No match was found for the specified search criteria and module name 'PackageManagement'. Try Get-PSRepository to see all available
 registered module repositories.
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1:1772 char:21
+ ...          $null = PackageManagement\Install-Package @PSBoundParameters
+                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Microsoft.Power....InstallPackage:InstallPackage) [Install-Package], Exception
    + FullyQualifiedErrorId : NoMatchFoundForCriteria,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackage

When I try to run the same command from my OS's powershell console, it works as expected.

I use TLS1.2 as security protocol.

Kind regards

Environment Information

Visual Studio Code

| Name | Version |
| --- | --- |
| Operating System | Windows_NT x64 6.3.9600 |
| VSCode | 1.46.0|
| PowerShell Extension Version | 2020.6.0 |

PowerShell Information

|Name|Value|
|---|---|
|PSVersion|5.1.14409.1018|
|PSEdition|Desktop|
|PSCompatibleVersions|1.0 2.0 3.0 4.0 5.0 5.1.14409.1018|
|BuildVersion|10.0.14409.1018|
|CLRVersion|4.0.30319.42000|
|WSManStackVersion|3.0|
|PSRemotingProtocolVersion|2.3|
|SerializationVersion|1.1.0.1|

Visual Studio Code Extensions

Visual Studio Code Extensions(Click to Expand)

|Extension|Author|Version|
|---|---|---|
|code-spell-checker|streetsidesoftware|1.9.0|
|csharp|ms-dotnettools|1.22.0|
|csharp2ts|rafaelsalguero|0.0.24|
|debugger-for-chrome|msjsdiag|4.12.8|
|githistory|donjayamanne|0.6.5|
|mssql|ms-mssql|1.9.0|
|powershell|ms-vscode|2020.6.0|
|react-native-snippet|jundat95|0.5.6|
|vscode-docker|ms-azuretools|1.2.1|
|vscode-eslint|dbaeumer|2.1.5|
|vscode-react-native|msjsdiag|0.16.0|
|vscode-typescript-tslint-plugin|ms-vscode|1.2.3|
|xml|DotJoshJohnson|2.5.0|

Area-Startup Issue-Bug Up-for-Grabs

Most helpful comment

the powershell command to install the update should include the command to use TLS1.2

powershell.exe -NoLogo -NoProfile -Command '[Net.ServicePointManager]::SecurityProtocol=[Net.SecurityProtocolType]::Tls12; Install-Module -Name PackageManagement -Force -MinimumVersion 1.4.6 -Scope CurrentUser -AllowClobber

All 12 comments

This looks very much like the problem I had a few weeks ago. You can't download from the PSGallery because you aren't using TLS1.2. Try using the following before attempting your command:
That will force TLS1.2 (instead of the default 1.0 on some older systems)

This looks very much like the problem I had a few weeks ago. You can't download from the PSGallery because you aren't using TLS1.2. Try using the following before attempting your command:

[Net.ServicePointManager]::SecurityProtocol=[Net.SecurityProtocolType]::Tls12

That will force TLS1.2 (instead of the default 1.0 on some older systems)

I鈥檓 using TLS1.2, and it works when I run the command from powershell console. It doesn鈥檛 work when I鈥檓 in vscode. Even if I install the module via powershell console, when I open vscode, it tries to install again.

the powershell command to install the update should include the command to use TLS1.2

powershell.exe -NoLogo -NoProfile -Command '[Net.ServicePointManager]::SecurityProtocol=[Net.SecurityProtocolType]::Tls12; Install-Module -Name PackageManagement -Force -MinimumVersion 1.4.6 -Scope CurrentUser -AllowClobber

I ran into the same issue after latest vscode-powershell update. The experience of the update is not great. Extension itself offers to perform an upgrade, but never completes that. No good guidance on how to deal with this manually is given too.

Thanks everyone for commenting on this issue. We need to update our script to accommodate the changes to TLS--we arent working on this at the moment so if anyone would like to open a PR to make this change the change can be made here:
https://github.com/PowerShell/vscode-powershell/files/4770760/Logs.log

the powershell command to install the update should include the command to use TLS1.2

powershell.exe -NoLogo -NoProfile -Command '[Net.ServicePointManager]::SecurityProtocol=[Net.SecurityProtocolType]::Tls12; Install-Module -Name PackageManagement -Force -MinimumVersion 1.4.6 -Scope CurrentUser -AllowClobber

This command did work for me! Great thank you! :)

Had a similar issue: updated to the new 2020.6 which caused a bunch of problems:

  • notification saying my packagement module was outdated and might cause problems, select yes to update => installed successfully, but couldn't run any PowerShell
  • Everytime I restarted VSC it said the same, please update PackageManagement, PowerShell crashed.
  • Installed the dotnet version of PowerShell > terminal didn't even start no more?? Exit code 1, An error message popped-up saying something of "> is resorved for later use" => crash
  • Tried several things, including reinstalling the PowerShell extension plugin, installing the 2020.6.1 preview (and disabling the stable 2020.6.0 one), reinstalled VSC, ... Nothing seemed to work, and I couldn't even get the menu to switch to another PowerShell version ("PowerShell takes longer to start than usual"). Went to the settings.json to change the directory to the dotnet core powershell, but didn't work.

Eventually what saved me (at least for the moment it seems) was executing the command @MSIH wrote, but with 1 exception: changed -Scope CurrentUser to Allusers=>
powershell.exe -NoLogo -NoProfile -Command '[Net.ServicePointManager]::SecurityProtocol=[Net.SecurityProtocolType]::Tls12; Install-Module -Name PackageManagement -Force -MinimumVersion 1.4.6 -Scope AllUsers -AllowClobber -Verbose'

No more anoying popup about the Packagemanger.
Also I could get back into the settings.json and added the following line:
"powershell.powerShellDefaultVersion": "Windows PowerShell (x64)"

Finally I can work again :-)

the powershell command to install the update should include the command to use TLS1.2

powershell.exe -NoLogo -NoProfile -Command '[Net.ServicePointManager]::SecurityProtocol=[Net.SecurityProtocolType]::Tls12; Install-Module -Name PackageManagement -Force -MinimumVersion 1.4.6 -Scope CurrentUser -AllowClobber

Worked perfect :), thanks!

Still happening, none of the solutions worked for me. I always get "The version '1.4.7' of module 'PackageManagement' is currently in use."

Still happening, none of the solutions worked for me. I always get "The version '1.4.7' of module 'PackageManagement' is currently in use."

@mvhecht are you running the preview extension? I believe this is fixed in that extension.

Eventually what saved me (at least for the moment it seems) was executing the command @MSIH wrote, but with 1 exception: changed -Scope CurrentUser to Allusers=>
powershell.exe -NoLogo -NoProfile -Command '[Net.ServicePointManager]::SecurityProtocol=[Net.SecurityProtocolType]::Tls12; Install-Module -Name PackageManagement -Force -MinimumVersion 1.4.6 -Scope AllUsers -AllowClobber -Verbose'

_Originally posted by @nilsvbconxion in https://github.com/PowerShell/vscode-powershell/issues/2763#issuecomment-645840720_

This worked for me, but had to run VS Code as Administrator first and then run the above command.
The update is applied to All Users (as the command suggests).

Still happening, none of the solutions worked for me. I always get "The version '1.4.7' of module 'PackageManagement' is currently in use."

_Originally posted by @mvhecht in https://github.com/PowerShell/vscode-powershell/issues/2763#issuecomment-712984335_

Try running VS Code as Administrator.

Man, I have been having this update issues for months. Glad I stumbled across this. powershell.exe -NoLogo -NoProfile -Command '[Net.ServicePointManager]::SecurityProtocol=[Net.SecurityProtocolType]::Tls12; Install-Module -Name PackageManagement -Force -MinimumVersion 1.4.6 -Scope AllUsers -AllowClobber -Verbose' Was the one that worked for me in the end.

Was this page helpful?
0 / 5 - 0 ratings