Vscode-powershell: "You have an older version of PackageManagement..." Prompts Repeatedly

Created on 22 Jul 2020  路  85Comments  路  Source: PowerShell/vscode-powershell

System Details

System Details Output

### VSCode version: 1.47.2 17299e413d5590b14ab0340ea477cdd86ff13daf x64

### VSCode extensions:
[email protected]
[email protected]
[email protected]
[email protected]   
[email protected]
[email protected]
[email protected]        
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]


### PSES version: 2.2.0.0

### PowerShell version:

Name                           Value
----                           -----
PSVersion                      5.1.18362.752
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.18362.752
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

Issue Description

When I open a project, I am prompted with this probably 80% of the time. I've run it repeatedly, but it doesn't seem to make a difference.

image

If I click "Yes", this command is run"

PS D:\code\Denholtz\Deployment> powershell.exe -NoLogo -NoProfile -Command 'Install-Module -Name PackageManagement -Force -MinimumVersion 1.4.6 -Scope CurrentUser -AllowClobber'

Expected Behaviour

One prompt makes sense if I'm out of date. But it simply repeats.

Actual Behaviour

Too many prompts.

Area-Startup Issue-Bug Needs Resolution-Answered

Most helpful comment

ALRIGHT. Finally found a solution. This packagemanagement issue has been driving me nuts. Seeing it every single time I open VScode, and errors when I need to install a new module or package. There may be an easier way, but here's how I resolved it since all the suggested install commands would error for me.

MODULE PATHS
C:\Program Files (x86)\WindowsPowerShell\Modules
C:\Program Files\WindowsPowerShell\Modules
C:\Windows\System32\WindowsPowerShell\v1.0\Modules

POWERSHELL GALLERY PATHS
https://www.powershellgallery.com/packages/PackageManagement/
https://www.powershellgallery.com/packages/PowerShellGet/

Step 1) Access each Module Path.
Step 2) Delete PowerShellGet & PackageManagement
(Note: I make copies of everything before I delete because I'm paranoid, and the copies need to be stored a level above the Modules folder or somewhere else altogether, just not in the Modules folder)
Step 3) Access PowerShell Gallery Paths
Step 4) Manual Download -> Download the RAW NUPKG file
Step 5) Rename extension to ZIP Example: powershellget.2.2.1.nupkg to powershellget.2.2.1.zip
Step 6) Unzip
Step 7) Copy the unzipped folder to C:\Windows\System32\WindowsPowerShell\v1.0\Modules
Step 8) REMOVE the version numbers from both folder names. Leaving only powershellget & packagemanagement
Step 9) Open VScode as administrator
Step 10) Enjoy never having Vscode complain about packagemanagement & a problem-free module/package installation experience

All 85 comments

Hi,
I have exactly the same error as described above.
Also a re-installation of "_ms-vscode.PowerShell_" wasn't successfull.

Message which will be displayed:
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)?

Command which will be executed if I click on "Yes":
powershell.exe -NoLogo -NoProfile -Command 'Install-Module -Name PackageManagement -Force -MinimumVersion 1.4.6 -Scope CurrentUser -AllowClobber'

Message which appears after the command was successfully executed:
PackageManagement updated, If you already had PackageManagement loaded in your session, please restart the PowerShell extension.

Directly afterwards the initial message appears again.
This only happens twice to me.


### VSCode version: 

Version: 1.47.2 (user setup)
Commit: 17299e413d5590b14ab0340ea477cdd86ff13daf


### PowerShell version:

Name                           Value
----                           -----
PSVersion                      5.1.18362.752
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.18362.752
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1


### VSCode extensions:

bencoleman.armview
ckolkman.vscode-postgres
donjayamanne.githistory
eamodio.gitlens
hashicorp.terraform
jmrog.vscode-nuget-package-manager
ms-dotnettools.vscode-dotnet-runtime
ms-vscode-remote.remote-ssh
ms-vscode-remote.remote-ssh-edit
ms-vscode.powershell
ms-vsts.team
msazurermtools.azurerm-vscode-tools

I have been getting the same issue for about a month issue. When I run the update requested I get an error:

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)?

PS E:\todd\Repos\Evolve-iMS\UNIT001_Apps> powershell.exe -NoLogo -NoProfile -Command 'Install-Module -Name PackageManagement -Force -MinimumVersion 1.4.6 -Scope CurrentUser
-AllowClobber'
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.6.0\PSModule.psm1:2057 char:21
... $null = PackageManagement\Install-Package @PSBoundParameters
~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Microsoft.Power....InstallPackage:InstallPackage) [Install-Package], Exception
+ FullyQualifiedErrorId : NoMatchFoundForCriteria,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackage

PS E:\todd\Repos\Evolve-iMS\UNIT001_Apps>get-psrepository

WARNING: MSG:UnableToDownloadhttps://go.microsoft.com/fwlink/?LinkID=627338&clcid=0x409禄 芦禄
WARNING: Unable to download the list of available providers. Check your internet connection.

Name InstallationPolicy SourceLocation
---- ------------------ --------------
PSGallery Untrusted https://www.powershellgallery.com/api/v2/

Environment Information

Visual Studio Code

| Name | Version |
| --- | --- |
| Operating System | Windows_NT x64 10.0.14393 |
| VSCode | 1.47.3|
| PowerShell Extension Version | 2020.6.0 |

PowerShell Information

|Name|Value|
|---|---|
|PSVersion|5.1.14393.3471|
|PSEdition|Desktop|
|PSCompatibleVersions|1.0 2.0 3.0 4.0 5.0 5.1.14393.3471|
|BuildVersion|10.0.14393.3471|
|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|
|---|---|---|
|al|ms-dynamics-smb|5.0.288712|
|al-code-outline|andrzejzwierzchowski|2.0.5|
|al-object-designer|martonsagi|0.2.2|
|crs-al-language-extension|waldo|1.2.4|
|gc-excelviewer|GrapeCity|3.0.39|
|gitlens|eamodio|10.2.2|
|navertical|Kine|0.5.6|
|powershell|ms-vscode|2020.6.0|
|team|ms-vsts|1.161.0|
|todo-tree|Gruntfuggly|0.0.178|
|vscode-guid|heaths|1.4.20|
|vsliveshare|ms-vsliveshare|1.0.2478|
|xml|DotJoshJohnson|2.5.1|

What is the output of gmo PackageManagement -ListAvailable in the integrated console?

Before reinstalling PackageManagement:

    Directory: C:\Program Files\WindowsPowerShell\Modules


ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Binary     1.0.0.1    PackageManagement                   {Find-Package, Get-Package, Get-PackageProvider, Get-PackageSource...}

Command which runs:

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

After reinstalling PackageManagement:

    Directory: C:\Program Files\WindowsPowerShell\Modules


ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Binary     1.0.0.1    PackageManagement                   {Find-Package, Get-Package, Get-PackageProvider, Get-PackageSource...}

Before and after look the same to me...

@sympmarc does any error output appear in the integrated console?

No error at all. Just the prompt to reinstall PackageManager.

Since I posted the issue, I think I've figured out the pattern. The prompt comes up each time I open a new project folder, no matter how many other projects folders I have open in other VS Code windows. The prompt comes up right as the terminal window is revving up.

From that point forward in the project folder session, everything is fine.

If it's helpful, the prompt in the PowerShell Integrated Console is this:

=====> PowerShell Integrated Console v2020.6.0 <=====

PS D:\code\[...]> 

If I garbage can the terminal window for any reason, I'm prompted again.

Ok, given that, I think your logs might be useful here

Here are the logs from one PS terminal session. I can broaden out if that is useful.

1595969526-8689461e-d76d-4354-9e2a-0f05974d7ce41595969454260.zip

Strangely, there doesn't seem to be any report of failure:

2020-07-28 16:52:16.270 -04:00 [VRB] Attempting to execute command(s):

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

It doesn't really feel like a failure, per se. It's more like the session doesn't see the installed version of PackageManager and thinks it needs a new install.

Here's a log with the reinstallation included.
1595970085-39394155-83d7-4431-b0d9-d0f1a64238f21595970040956.zip

Thanks @sympmarc we actually just released an update to our Preview extension which has addressed a Package Management bug, would you mind giving it a try and letting us know if you are still hitting this issue?

Good morning,
installed the linked preview.

Got now the _"=====> PowerShell Preview Integrated Console v2020.7.0 <====="_

Unfortunately, after the VSC was restarted I got the message _"The 'PowerShell' extension is recommended for this file type."_
following by _"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)?"_

If I click on "_No_" and press F5 for debugging my powershell code another message "_Cannot debug or run a PowerShell script until the PowerShell session has started. Wait for the PowerShell session to finish starting and try again."_ appeared.

If I click on "_Yes_" the following code will be executed:
powershell.exe -NoLogo -NoProfile -Command '[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; Install-Module -Name PackageManagement -Force -MinimumVersion 1.4.6 -Scope CurrentUser -AllowClobber -Repository PSGallery'

After the installation I got the message "PackageManagement updated, If you already had PackageManagement loaded in your session, please restart the PowerShell extension."

Now, the initial message _"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)?"_
popups again and I repeated it as described above.

I've installed the preview and disabled the older version. When I opened a new project, I'm still seeing the prompt and installing the extension and restarting the PowerShell extension lands me in the same place (as @kaiaschulz outlines above).

image

@sympmarc what happens when you hit "yes"

Sorry, I probably wasn't clear. If I install PackageManagement and restart the extension, I'm right back to the same place. In other words, this latest extension preview doesn't change anything. I have the same experience as @kaiaschulz.

What version of PackageManagement do you have?

Before reinstalling PackageManagement:

    Directory: C:\Program Files\WindowsPowerShell\Modules


ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Binary     1.0.0.1    PackageManagement                   {Find-Package, Get-Package, Get-PackageProvider, Get-PackageSource...}

Command which runs:

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

After reinstalling PackageManagement:

    Directory: C:\Program Files\WindowsPowerShell\Modules


ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Binary     1.0.0.1    PackageManagement                   {Find-Package, Get-Package, Get-PackageProvider, Get-PackageSource...}

Before and after look the same to me...

Same as above.

Have you tried manually running that command? Does anything happen?

Sorry for the lag. I just ran the command manually. PackageManagement is definitely installed, whether I run the command manually or by clicking 'Yes' in the prompt. It's the standard teal progress indicator you see when you install any module.

I just tried to run through this as administrator, in case it mattered, but no difference. (I'm pretty sure I'd tried that already.)

When I get the prompt to restart the PowerShell Extension, I'm just clicking the garbage can on the terminal session, which reloads it. Should I be doing something different? A restart of VS Code altogether doesn't solve it, either.

After it ran, what does:

gmo -list PackageManagement

give you?

You should have a 1.4.7 _somewhere_ in the PSModulePath:

https://www.powershellgallery.com/packages/PackageManagement/1.4.7

I wonder if running it with -Verbose would shed any light. It seems very strange that the command runs, doesn't seem to fail, but does not install anything

The package version doesn't change. It's the same before and after updating.

image

The line it runs is this:
powershell.exe -NoLogo -NoProfile -Command '[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; Install-Module -Name PackageManagement -Force -MinimumVersion 1.4.6 -Scope CurrentUser -AllowClobber -Repository PSGallery'

That's 1.4.6. For grins and giggles, I tried 1.4.7 - no difference.

Adding -Verbose:
image

No idea why it would be installing to D:\OneDrive\Documents\WindowsPowerShell\Modules

Ok, next question: what is the result of $env:PSModulePath -split ';'?

No idea why it would be installing to D:\OneDrive\Documents\WindowsPowerShell\Modules

What's the result of [environment]::getfolderpath('mydocuments')?

image

As I suspected. PowerShellGet is using the special system folder API to guess the module install location, but PowerShell doesn't use that. Why I opened https://github.com/PowerShell/PowerShell/issues/7082.

I suspect the GetFolderPath() result is because OneDrive has frustratingly mangled your settings.

The way to solve this in your case is to Save-Module PackageManagement -MinimumVersion 1.4.7 -LiteralPath 'C:\Users\mdent\Documents\WindowsPowerShell\Modules\ (may need to massage that command a bit).

I would say this is a bug in PowerShellGet, but given that this feature is intended to move old systems (that aren't going to get a new version of either PSGet or PackageManagement without help) off of an old (and by old I mean like 5 years old) module version that deadlocks us just by being loaded, we may need to think of a better strategy. Honestly, just being able to permanently dismiss the notification would be helpful. Especially if work I'm currently doing can prevent the deadlock on our end...

Thanks for sticking with us btw @sympmarc!

That fixed it! Hey, no problem. We're all in this together. Than you for sticking with me!

Hey. I still have the same issue as before even if the package version was already on 1.4.7 and located in the mentioned path C:\Users\%username%\Documents\WindowsPowerShell\Modules above


[environment]::getfolderpath('mydocuments')

C:\Users\%username%\Documents

$env:PSModulePath -split ';'

C:\Users\%username%\AppData\Local\Google\Cloud SDK\google-cloud-sdk\platform\PowerShell
C:\Program Files (x86)\WindowsPowerShell\Modules
C:\Program Files\WindowsPowerShell\Modules
C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules
C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk\platform\PowerShell
C:\Program Files (x86)\AWS Tools\PowerShell\
C:\Program Files (x86)\Microsoft Azure Information Protection\Powershell
c:\Users\%username%\.vscode\extensions\ms-vscode.powershell-preview-2020.7.0\modules 

In C:\Program Files (x86)\WindowsPowerShell\Modules and C:\Program Files\WindowsPowerShell\Modules was the old PackageManagement version 1.0.0.1

Regarding to this, I executed the mentioned command above for both pathes with administrative rights:
Save-Module PackageManagement -MinimumVersion 1.4.7 -LiteralPath 'C:\Program Files\WindowsPowerShell\Modules'
Save-Module PackageManagement -MinimumVersion 1.4.7 -LiteralPath 'C:\Program Files (x86)\WindowsPowerShell\Modules'

Afterwards the folders 1.4.7 were available.


Now, it seem to be fixed! Thanks a lot for all your help!

Nevertheless, why did the problem still persist even if the environment seem to be correctly set and the version was updated? [environment]::getfolderpath('mydocuments')

Nevertheless, why did the problem still persist even if the environment seem to be correctly set and the version was updated?

Your module path is different to the conventional default that PSGet expects — it seems strange that you have both x86 and normal module directories on the same module path; usually you only want either 32-bit or 64-bit locations on your module path.

My guess is that PSGet installed the module correctly to your 64-bit user path, but because the 32-bit path precedes it, you would always import the lower version out of preference. One way to fix that is to remove the lower versions of the module that appear when you run gmo -list PackageManagement

I have a different issue. It prompts repeatedly, but the version never updates.

gmo -list PackageManagement before prompt:

Directory: C:\Program Files\WindowsPowerShell\Modules


ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Binary     1.0.0.1    PackageManagement                   {Find-Package, Get-Package, Get-PackageProvider, Get-Packa...

Output in console when updating:

powershell.exe -NoLogo -NoProfile -Command 'Install-Module -Name PackageManagement -Force -MinimumVersion 1.4.6 -Scope CurrentUser -AllowClobber'
WARNING: (0) : No source files specified

(1) : using System;

gmo -list PackageManagement after:

Directory: C:\Program Files\WindowsPowerShell\Modules


ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Binary     1.0.0.1    PackageManagement                   {Find-Package, Get-Package, Get-PackageProvider, Get-Packa...

What could be the cause of this?

Try opening a new powershell.exe console and running Install-Module -Name PackageManagement -Force -MinimumVersion 1.4.6 -Scope CurrentUser -AllowClobber -Verbose.

If you show us the full output of that, and if there's an error, $error[0] | fl * -force, we might have a better chance of debugging it.

Output of Install-Module:

WARNING: (0) : No source files specified
                                                                                                                        (1) : using System;                                                                                                     VERBOSE: The -Repository parameter was not specified.  PowerShellGet will use all of the registered repositories.       VERBOSE: Getting the provider object for the PackageManagement Provider 'NuGet'.                                        VERBOSE: The specified Location is 'https://www.powershellgallery.com/api/v2' and PackageManagementProvider is 'NuGet'. VERBOSE: Searching repository 'https://www.powershellgallery.com/api/v2/FindPackagesById()?id='PackageManagement'' for
''.
VERBOSE: Total package yield:'2' for the specified package 'PackageManagement'.
VERBOSE: Performing the operation "Install-Module" on target "Version '1.4.7' of module 'PackageManagement'".
VERBOSE: The installation scope is specified to be 'CurrentUser'.
VERBOSE: The specified module will be installed in 'C:\Users\Pika\Documents\WindowsPowerShell\Modules'.
VERBOSE: The specified Location is 'NuGet' and PackageManagementProvider is 'NuGet'.
VERBOSE: Downloading module 'PackageManagement' with version '1.4.7' from the repository
'https://www.powershellgallery.com/api/v2'.
VERBOSE: Searching repository 'https://www.powershellgallery.com/api/v2/FindPackagesById()?id='PackageManagement'' for
''.
VERBOSE: InstallPackage' - name='PackageManagement',
version='1.4.7',destination='C:\Users\Pika\AppData\Local\Temp\1604792502'
VERBOSE: DownloadPackage' - name='PackageManagement',
version='1.4.7',destination='C:\Users\Pika\AppData\Local\Temp\1604792502\PackageManagement\PackageManagement.nupkg',
uri='https://www.powershellgallery.com/api/v2/package/PackageManagement/1.4.7'
VERBOSE: Downloading 'https://www.powershellgallery.com/api/v2/package/PackageManagement/1.4.7'.
VERBOSE: Completed downloading 'https://www.powershellgallery.com/api/v2/package/PackageManagement/1.4.7'.
VERBOSE: Completed downloading 'PackageManagement'.
VERBOSE: Hash for package 'PackageManagement' does not match hash provided from the server.
VERBOSE: InstallPackageLocal' - name='PackageManagement',
version='1.4.7',destination='C:\Users\Pika\AppData\Local\Temp\1604792502'
VERBOSE: Catalog file 'PackageManagement.cat' is not found in the contents of the module 'PackageManagement' being
installed.
VERBOSE: Valid authenticode signature found in the file 'PackageManagement.psd1' for the module 'PackageManagement'.

I didn't see an error in this output, but I ran $error[0] | fl * -force anyways:

PSMessageDetails      :
Exception             : System.InvalidOperationException: Cannot add type. Compilation errors occurred.
                           at System.Management.Automation.MshCommandRuntime.ThrowTerminatingError(ErrorRecord
                        errorRecord)
TargetObject          :
CategoryInfo          : InvalidData: (:) [Add-Type], InvalidOperationException
FullyQualifiedErrorId : COMPILER_ERRORS,Microsoft.PowerShell.Commands.AddTypeCommand
ErrorDetails          :
InvocationInfo        : System.Management.Automation.InvocationInfo
ScriptStackTrace      : at <ScriptBlock>, C:\Program
                        Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1: line 732
                        at <ScriptBlock>, <No file>: line 1
PipelineIterationInfo : {}

Running gmo -list PackageManagement still shows 1.0.0.1

Looks like you're hitting an issue in PowerShellGet 1.0.0.1. Try updating PowerShellGet first: Install-Module PowerShellGet -AllowClobber -Scope CurrentUser -Force -Verbose. Then you'll need to open a new PowerShell process and try installing PackageManagement again

Nope, that didn't work. Version is still 1.0.0.1

Can you show the result of gmo -list PowerShellGet?

Directory: C:\Program Files\WindowsPowerShell\Modules


ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Script     1.0.0.1    PowerShellGet                       {Install-Module, Find-Module, Save-Module, Update-Module...}

Ok, I'm guessing you have a faulty PowerShellGet installation.

Try:

  • Downloading this zip: PSGet.zip
  • Expand-Archive ./PSGet.zip ./PowerShellGet
  • mkdir ~/Documents/WindowsPowerShell/Modules (may error, not an issue)
  • Move-Item ./PowerShellGet ~/Documents/WindowsPowerShell/Modules

The let us know what gmo -list PowerShellGet outputs

Directory: C:\Program Files\WindowsPowerShell\Modules


ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Script     1.0.0.1    PowerShellGet                       {Install-Module, Find-Module, Save-Module, Update-Module...}

How about $env:PSModulePath

C:\Users\Pika\Documents\WindowsPowerShell\Modules;C:\Program Files\WindowsPowerShell\Modules;C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules

ls ~/Documents/WindowsPowerShell/Modules?

only directory there is PowerShellGet

Ok I'm assuming ~ maps to C:\Users\Pika -- does gi ~ | % FullName give you back C:\Users\Pika?

What does gmo -list PowerShellGet -Verbose look like?

Other thing to try is to take the downloaded, unzipped PowerShellGet and import it directly with ipmo -Force ~/Documents/WindowsPowerShell/Modules/PowerShellGet and confirm your version with gmo PowerShellGet

That fixed it! Hey, no problem. We're all in this together. Than you for sticking with _me_!

Unfortunately, while I thought this was "fixed" for me, it's still happening in some of my projects.

Ok I'm assuming ~ maps to C:\Users\Pika -- does gi ~ | % FullName give you back C:\Users\Pika?

Yes.

VERBOSE: Loading module from path 'C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1'.


    Directory: C:\Program Files\WindowsPowerShell\Modules


ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Script     1.0.0.1    PowerShellGet                       {Install-Module, Find-Module, Save-Module, Update-Module...}

Why do you think this is happening?

Ok rather than me try to give you individual commands to run, which I don't think is working well and is taking time away from other issues, I think it's best for me to give some general directions.

I both cases here I think your machines have some state or configuration that goes against the assumptions of the PackageManagement/PowerShellGet installations that currently exist on them. Specifically in one case PackageManagement is failing for some reason and needs to be replaced, and in the other PowerShellGet's assumptions about the module path are wrong. So our goal is to put your machines into a state where PackageManagement/PowerShellGet are up to date, work and are available on the PSModulePath.

To fix this, you need to:

  • Manually download PackageManagement 1.4.7 and PowerShellGet 2.2.4.1. The simplest way to do this is with Save-Module. If that doesn't work on your local machine, the next easiest option is probably to use Save-Module from another device and copy the asset over. If that's not an option, you can download the nupkg for the modules directly and use expand-archive to restore them to module form.
  • In a fresh PowerShell session started with the -noprofile flag (easiest to start from CMD like powershell -noprofile), import these modules by path from where you've downloaded them
  • Run Install-Module PackageManagement -MinimumVersion 1.4.7 -Verbose and Install-Module PowerShellGet -MinimumVersion 2.2.4.1 -Verbose to do a proper module installation
  • Ensure your $env:PSModulePath has the directories where those modules were installed. If it doesn't, add a line in your $PROFILE that prefixes the $env:PSModulePath with the directory.
  • Verify that the modules are installed and available with gmo -List

Thanks for the detailed instructions.

I get to the point where I run Install-Module, and this is the output:

VERBOSE: The installation scope is specified to be 'CurrentUser'.
VERBOSE: The specified module will be installed in 'C:\Users\Pika\Documents\WindowsPowerShell\Modules'.
VERBOSE: The specified Location is 'NuGet' and PackageManagementProvider is 'NuGet'.
VERBOSE: Downloading module 'PackageManagement' with version '1.4.7' from the repository
'https://www.powershellgallery.com/api/v2'.
VERBOSE: Searching repository 'https://www.powershellgallery.com/api/v2/FindPackagesById()?id='PackageManagement'' for
''.
VERBOSE: InstallPackage' - name='PackageManagement',
version='1.4.7',destination='C:\Users\Pika\AppData\Local\Temp\111535631'
VERBOSE: DownloadPackage' - name='PackageManagement',
version='1.4.7',destination='C:\Users\Pika\AppData\Local\Temp\111535631\PackageManagement\PackageManagement.nupkg',
uri='https://www.powershellgallery.com/api/v2/package/PackageManagement/1.4.7'
VERBOSE: Downloading 'https://www.powershellgallery.com/api/v2/package/PackageManagement/1.4.7'.
VERBOSE: Completed downloading 'https://www.powershellgallery.com/api/v2/package/PackageManagement/1.4.7'.
VERBOSE: Completed downloading 'PackageManagement'.
VERBOSE: Hash for package 'PackageManagement' does not match hash provided from the server.
VERBOSE: InstallPackageLocal' - name='PackageManagement',
version='1.4.7',destination='C:\Users\Pika\AppData\Local\Temp\111535631'
VERBOSE: Catalog file 'PackageManagement.cat' is not found in the contents of the module 'PackageManagement' being
installed.
VERBOSE: Valid authenticode signature found in the file 'PackageManagement.psd1' for the module 'PackageManagement'.

C:\Users\Pika\Documents\WindowsPowerShell\Modules is empty in the end, though...
I have permissions to create files and such in this folder...

What else could this be?

edit: same results if -Scope CurrentUser is specified as well...

I assume the currently imported versions of PowerShellGet and PackageManagement are the right ones? What does gmo PowerShellGet and gmo PackageManagement tell you?

Yes:

ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Script     2.2.4.1    PowerShellGet                       {Find-Command, Find-DscResource, Find-Module, Find-RoleCap...
ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Script     1.4.7      PackageManagement                   {Find-Package, Find-PackageProvider, Get-Package, Get-Pack...

Ok what are the outputs of:

  • $PSHOME
  • [environment]::getfolderpath('mydocuments')
  • [environment]::getfolderpath('programfiles')
  • $env:PROCESSOR_ARCHITECTURE

$PSHOME

C:\Windows\System32\WindowsPowerShell\v1.0

[environment]::getfolderpath('mydocuments')

C:\Users\Pika\Documents

[environment]::getfolderpath('programfiles')

C:\Program Files

$env:PROCESSOR_ARCHITECTURE

AMD64

Ok that doesn't indicate anything strange, which is bad since there's nothing to fix.

Try moving the downloaded PackageManagement and PowerShellGet into your current user module path (~/Documents/WindowsPowerShell/Modules) and see if you at least pick those modules up with gmo -list.

If that doesn't work, I'm not sure what's going on. The issues seem to be with PowerShellGet and PackageManagement, which are external to this repository.

I do pick up those modules, yes.

I'm honestly confused how any of this happened, to be honest. I've never touched PSGet or PowerShell at all, really.

I do pick up those modules, yes.

Ok, if they're being picked up from the module path now, then hopefully that solves the issue. Certainly PackageManagement should now register as 1.4.7

Yes, it does. Yay!

Is there anything I can do to "clean-up" whatever is faulty, or is there nothing to clean up, or...?

Thanks for all your help!

Is there anything I can do to "clean-up" whatever is faulty

Well the existing modules are the ones that come with Windows, so probably not a good idea to remove them. But as long as you have a newer version installed ahead of them on the module path, it should all work as expected.

Also, I deleted the old versions of PackageManagement and PSGet in C:\Program Files\WindowsPowerShell\Modules. Will this break--

oh.

Okay, time to restore them from Recycle Bin.

Thanks for all your help!

Just got the same issue (couldn't update packagemanagement) and bumped into this thread.

Perhaps it's already somewhere up here in the discussion but in my case it was a case of using tls 1.2
(see https://dev.to/darksmile92/powershell-disabled-support-for-tls-1-0-for-the-gallery-update-module-and-install-module-broken-1oii)

Updated PowerShellGet like this:

PS C:\windows\system32> [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
PS C:\windows\system32> Install-Module PowerShellGet -RequiredVersion 2.2.4 -SkipPublisherCheck

And gone was the error in vs code

In the PowerShell Preview extension we now set Tls 1.2 when installing. This should fix most of the issues talked about in this thread.

A handful of you have issues that a result of where PowerShellGet installs modules and what PSModulePaths PowerShell uses. For you folks, there's not much we can do in the extension and I highly encourage opening an issue on PowerShell itself or PowerShellGet.

I'll mark this as "resolution answered" but this issue will live on as reference for others who experience this.

If you are seeing this popup: "You have an older version of PackageManagement...", everytime you launch VSCode, below steps should resolve your issues.

Setting the TLS protocol to 1.2 with this command:
Then, install PackageManagement module with this command:
Install-Module -Name PackageManagement -Force
Will install the latest version: 1.4.7

The above 2 commands should resolve the PackageManagement pop-up issue

Why hasn't a TLS fix been shipped with a Windows update or something? And why after so many updates does VS Code still have this issues? Low priority?

Why hasn't a TLS fix been shipped with a Windows update or something? And why after so many updates does VS Code still have this issues? Low priority?
@github-account1111

If I understand correctly, it can't be updated/shipped in windows because it would fundamentally change all .net framework applications. The extension has been patched to set this properly in the version that was just released so it should no longer be an issue for the extension.

Mine says a little different when I click Yes

powershell.exe -NoLogo -NoProfile -Command 'Install-Module -Name PackageManagement -Force -MinimumVersion 1.4.6 -Scope CurrentUser -AllowClobber'
Install-Module : A parameter cannot be found that matches parameter name 'Name'.

Then it says to run command manually, which shows another error.

Install-Module PackageManagement -Force -AllowClobber -MinimumVersion 1.4.6
Install-Module : A parameter cannot be found that matches parameter name "AllowClobber".

It's Windows 10 2009.

If you are seeing this popup: "You have an older version of PackageManagement...", everytime you launch VSCode, below steps should resolve your issues.
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
Install-Module -Name PackageManagement -Force

Doing this again throws error on parameter Name. Omitting -Name it says
Module PackageManagement was not found in central repository

Running these two lines posted by @walkingstar1 above in the terminal window has fixed the problem for me on 4 different machines:

[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
Install-Module -Name PackageManagement -Force

In one case, I needed to add -AllowClobber to the second line.

[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
Install-Module -Name PackageManagement -Force

Install-Module : A parameter cannot be found that matches parameter name 'Name'.

-AllowClobber
Install-Module : A parameter cannot be found that matches parameter name "AllowClobber".

@regs01 what's the output on your machine of gmo -List PowerShellGet,PackageManagement?

@regs01 that worked for me, thank you

ALRIGHT. Finally found a solution. This packagemanagement issue has been driving me nuts. Seeing it every single time I open VScode, and errors when I need to install a new module or package. There may be an easier way, but here's how I resolved it since all the suggested install commands would error for me.

MODULE PATHS
C:\Program Files (x86)\WindowsPowerShell\Modules
C:\Program Files\WindowsPowerShell\Modules
C:\Windows\System32\WindowsPowerShell\v1.0\Modules

POWERSHELL GALLERY PATHS
https://www.powershellgallery.com/packages/PackageManagement/
https://www.powershellgallery.com/packages/PowerShellGet/

Step 1) Access each Module Path.
Step 2) Delete PowerShellGet & PackageManagement
(Note: I make copies of everything before I delete because I'm paranoid, and the copies need to be stored a level above the Modules folder or somewhere else altogether, just not in the Modules folder)
Step 3) Access PowerShell Gallery Paths
Step 4) Manual Download -> Download the RAW NUPKG file
Step 5) Rename extension to ZIP Example: powershellget.2.2.1.nupkg to powershellget.2.2.1.zip
Step 6) Unzip
Step 7) Copy the unzipped folder to C:\Windows\System32\WindowsPowerShell\v1.0\Modules
Step 8) REMOVE the version numbers from both folder names. Leaving only powershellget & packagemanagement
Step 9) Open VScode as administrator
Step 10) Enjoy never having Vscode complain about packagemanagement & a problem-free module/package installation experience

@regs01 what's the output on your machine of gmo -List PowerShellGet,PackageManagement?

gmo -List PowerShellGet,PackageManagement

袣邪褌邪谢芯谐: C:\Program Files\WindowsPowerShell\Modules

ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Binary     1.0.0.1    PackageManagement                   {Find-Package, Get-Package, Get-PackageProvider, Get-PackageSource...}
Script     1.0.0.1    PowerShellGet                       {Install-Module, Find-Module, Save-Module, Update-Module...}

Edit. Found a problem thank to Internet. Had PSGet installed which was interfering with PowerShellGet. Probably some app installed, but don't remember installing it manually. Deleted it from Documents\WindowsPowerShell\Modules and it's now working.

I had the same problem and for me the resolution was making sure my powershell.powerShellDefaultVersion was correct and running Code as an Administrator. Somehow, over the course of troubleshooting this all day, I had gotten a value of "Windows PowerShell (x86)" in there. Changing that to Windows PowerShell (x64)" and running Code as an Administrator fixed the problem.

I was getting the recurring message about updating PackageManagement and even when I did get 1.4.7 installed as reported with Get-Module it still didn't work until I fixed my settings and started running Code as an admin.

This is far from ideal, but after spending a day wrestling with this problem, I need to accept it for now and move on. Maybe this will help someone else...

for anyone else getting this issue,
I've managed to solve it with this single command - this is somewhat modified version of the solution provided here by @rjmholt :
powershell.exe -NoLogo -NoProfile -Command 'Save-Module PackageManagement -MinimumVersion 1.4.7 -LiteralPath ""C:\Program Files\WindowsPowerShell\Modules\""'

In my case I suspect that the root cause is that my Documents folder is placed on a network folder.

Thanks @itsho, only with that command I was able to get rid of the popup. Even using powershell insider version 2020.9.0 was not able to resolve the install, regardless of running vscode it with admin or not

Running these two lines posted by @walkingstar1 above in the terminal window has fixed the problem for me on 4 different machines:

[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
Install-Module -Name PackageManagement -Force

In one case, I needed to add -AllowClobber to the second line.

This is the one that fixed it for me. Thank you!

Running these two lines posted by @walkingstar1 above in the terminal window has fixed the problem for me on 4 different machines:

[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
Install-Module -Name PackageManagement -Force

In one case, I needed to add -AllowClobber to the second line.

This solved it for me, too, except I also needed to add "-Repository PSGallery" to the command.

Had this issue as well. Found the culprit of my failure was Defender blocking the execution of the update. Allowed that and all good now after running the command manually.

I also have this issue but I found it was related to that the initial check is run using pwsh.exe but the installation is using powershell.exe.

If I install the module with -Scope CurrentUser for both pwsh and powershell i still get the prompt.

If I install the module for all users using pwsh, the prompt is gone.

In my case I suspect that the root cause is that my Documents folder is placed on a network folder.

Same here. Roaming profiles at work have our my documents on \ourdomain.local\mapped\etc\blah\\documents

ALRIGHT. Finally found a solution. This packagemanagement issue has been driving me nuts. Seeing it every single time I open VScode, and errors when I need to install a new module or package. There may be an easier way, but here's how I resolved it since all the suggested install commands would error for me.

MODULE PATHS
C:\Program Files (x86)\WindowsPowerShell\Modules
C:\Program Files\WindowsPowerShell\Modules
C:\Windows\System32\WindowsPowerShell\v1.0\Modules

POWERSHELL GALLERY PATHS
https://www.powershellgallery.com/packages/PackageManagement/
https://www.powershellgallery.com/packages/PowerShellGet/

Step 1) Access each Module Path.
Step 2) Delete PowerShellGet & PackageManagement
(Note: I make copies of everything before I delete because I'm paranoid, and the copies need to be stored a level above the Modules folder or somewhere else altogether, just not in the Modules folder)
Step 3) Access PowerShell Gallery Paths
Step 4) Manual Download -> Download the RAW NUPKG file
Step 5) Rename extension to ZIP Example: powershellget.2.2.1.nupkg to powershellget.2.2.1.zip
Step 6) Unzip
Step 7) Copy the unzipped folder to C:\Windows\System32\WindowsPowerShell\v1.0\Modules
Step 8) REMOVE the version numbers from both folder names. Leaving only powershellget & packagemanagement
Step 9) Open VScode as administrator
Step 10) Enjoy never having Vscode complain about packagemanagement & a problem-free module/package installation experience

This is the only solution that seemed to work for me out of all of them on this page. Thank you.

Running these two lines posted by @walkingstar1 above in the terminal window has fixed the problem for me on 4 different machines:

[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
Install-Module -Name PackageManagement -Force

In one case, I needed to add -AllowClobber to the second line.

I needed to run VS Code as admin, then run these commands, then reload. That did the trick. Thanks.

  • Get the PackageManagement module path (gmo -l PackageManagement).path
  • Create a folder of the version of your downloaded package (for me it's 1.4.7)
  • Download the latest version here (select manual download): https://www.powershellgallery.com/packages/PackageManagement/1.4.7
  • Use 7zip to extract the nupkg file then copy the extracted files to the created folder in the modules folder

I need to raise one thing since this issue is still affecting people (like me):

Inside of VSCode, the output of $env:PSModulePath -split ';' is:

C:\Program Files\WindowsPowerShell\Modules
C:\Users\nreiling\Documents\WindowsPowerShell\Modules
C:\Program Files (x86)\WindowsPowerShell\Modules     
C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules
C:\Program Files\Microsoft Message Analyzer\PowerShell\
c:\Users\nreiling\.vscode\extensions\ms-vscode.powershell-2021.2.2\modules

but OUTSIDE of VS Code it's:

C:\Users\nreiling\Documents\WindowsPowerShell\Modules
C:\Program Files\WindowsPowerShell\Modules
C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules
C:\Program Files\Microsoft Message Analyzer\PowerShell\

THE KEY DIFFERENCE here is that VS Code is importing modules from the -Scope AllUsers location over the -Scope CurrentUser location. You can also see this ordering in the output of Get-Module PackageManagement -ListAvailable -- I had v.1.4.4 installed in the Program Files directory and v.1.4.7 installed in my user directory. So what VS Code was doing is (successfully) updating PackageManagement in the user directory, and then importing the older version again right afterwards and complaining about it.

Understandably, VS Code can't try to update the Program Files module because this requires escalated privileges. But I have no idea why the module path ordering is different inside of VS code. Please @-mention me if you have any clues.

My solution was to use an elevated prompt to update the Program Files-based module. This was made difficult because unless you use the -Force flag to Install-Module or Update-Module, it will not affect a specified -Scope if the package is already installed in an alternate scope.

Anyway, here's how you diagnose and fix this version of the problem:

Inside the VS Code extension, run Get-Module PackageManagement -ListAvailable and note the directory location that is returned at the top of the output. This will match the ordering of $env:PSModulePath -split ';' in the same environment if you have this module installed in multiple locations. If the first-ordered location is C:\Program Files\WindowsPowerShell\Modules, then you can solve your VS Code woes by opening an elevated PowerShell prompt and running Update-Module PackageManagement -Scope AllUsers -Force.

If you are seeing this popup: "You have an older version of PackageManagement...", everytime you launch VSCode, below steps should resolve your issues.

Setting the TLS protocol to 1.2 with this command:
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12

Then, install PackageManagement module with this command:
Install-Module -Name PackageManagement -Force
Will install the latest version: 1.4.7

The above 2 commands should resolve the PackageManagement pop-up issue

Executing these two line in terminal window (as admin) solved the problem for me. Thank you very much :)

ALRIGHT. Finally found a solution. This packagemanagement issue has been driving me nuts. Seeing it every single time I open VScode, and errors when I need to install a new module or package. There may be an easier way, but here's how I resolved it since all the suggested install commands would error for me.

MODULE PATHS
C:\Program Files (x86)\WindowsPowerShell\Modules
C:\Program Files\WindowsPowerShell\Modules
C:\Windows\System32\WindowsPowerShell\v1.0\Modules

POWERSHELL GALLERY PATHS
https://www.powershellgallery.com/packages/PackageManagement/
https://www.powershellgallery.com/packages/PowerShellGet/

Step 1) Access each Module Path.
Step 2) Delete PowerShellGet & PackageManagement
(Note: I make copies of everything before I delete because I'm paranoid, and the copies need to be stored a level above the Modules folder or somewhere else altogether, just not in the Modules folder)
Step 3) Access PowerShell Gallery Paths
Step 4) Manual Download -> Download the RAW NUPKG file
Step 5) Rename extension to ZIP Example: powershellget.2.2.1.nupkg to powershellget.2.2.1.zip
Step 6) Unzip
Step 7) Copy the unzipped folder to C:\Windows\System32\WindowsPowerShell\v1.0\Modules
Step 8) REMOVE the version numbers from both folder names. Leaving only powershellget & packagemanagement
Step 9) Open VScode as administrator
Step 10) Enjoy never having Vscode complain about packagemanagement & a problem-free module/package installation experience

Works just fine!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

inthemedium picture inthemedium  路  3Comments

keposet picture keposet  路  3Comments

guidooliveira picture guidooliveira  路  3Comments

timoline picture timoline  路  3Comments

borisimple picture borisimple  路  3Comments