首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Powershell:无法更新PowerShellGet,错误:模块“PackageManagement”的版本“1.4.7”目前正在使用中

Powershell:无法更新PowerShellGet,错误:模块“PackageManagement”的版本“1.4.7”目前正在使用中
EN

Stack Overflow用户
提问于 2021-02-21 17:56:37
回答 2查看 24.7K关注 0票数 16

Win10笔记本电脑服务了几年。

我被困在这上面已经有几天了。

我尝试了以下命令:

代码语言:javascript
复制
Install-Module –Name PowerShellGet –Force -AllowClobber

引发此错误的

代码语言:javascript
复制
WARNING: The version '1.4.7' of module 'PackageManagement' 
is currently in use. Retry the operation after closing the applications.

我可以在任务管理器中看到,没有其他正在运行的powershell会话。

我可以退出所有会话,并从普通cmd运行以下操作:

代码语言:javascript
复制
powershell -NoProfile -Command "Install-Module -Name PowerShellGet -Force -AllowClobber"

和我得到了同样的错误.

好的,我退出所有powershell实例(如taskmgr的Details选项卡中所示)并执行以下操作:

代码语言:javascript
复制
powershell -NoProfile -Command "Uninstall-Module PowerShellGet"
powershell -NoProfile -Command "Install-Module -Name PowerShellGet -Force -AllowClobber"

和我得到了相同的错误。

因此,我再次进行卸载(它运行时没有消息或错误)。我拿出大枪..。powershell.exe没有运行,我导航到:

代码语言:javascript
复制
C:\Users\$user\Documents\WindowsPowerShell\Modules\PackageManagement\1.4.7

我删除了1.4.7目录。

上面的命令以相同的行为和相同的错误运行。

我该怎么通过这件事?

附加背景:

代码语言:javascript
复制
PS C:\WINDOWS\system32> Get-Module -ListAvailable PowerShellGet,PackageManagement


    Directory: C:\Program Files\WindowsPowerShell\Modules


ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Script     1.4.7      PackageManagement                   {Find-Package, Get-Package, Get-PackageProvider, Get-Packa...
Binary     1.0.0.1    PackageManagement                   {Find-Package, Get-Package, Get-PackageProvider, Get-Packa...
Script     2.2.5      PowerShellGet                       {Find-Command, Find-DSCResource, Find-Module, Find-RoleCap...
Script     1.0.0.1    PowerShellGet                       {Install-Module, Find-Module, Save-Module, Update-Module...}


PS C:\WINDOWS\system32>  Get-Module -ListAvailable PowerShellGet,PackageManagement | % path
C:\Program Files\WindowsPowerShell\Modules\PackageManagement\1.4.7\PackageManagement.psd1
C:\Program Files\WindowsPowerShell\Modules\PackageManagement\1.0.0.1\PackageManagement.psd1
C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\2.2.5\PowerShellGet.psd1
C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PowerShellGet.psd1

也尝试过

限制当前用户的范围:

代码语言:javascript
复制
PS C:\WINDOWS\system32> Install-Module -Name PowerShellGet -Force -Scope CurrentUser
WARNING: The version '1.4.7' of module 'PackageManagement' is currently in use. Retry the operation after closing the
applications.
PS C:\WINDOWS\system32> exit

# OK, check taskmgr that all powershell.exe have exited, and run the below
C:\WINDOWS\system32>powershell -command "Install-Module -Name PowerShellGet -Force -Scope CurrentUser"
WARNING: The version '1.4.7' of module 'PackageManagement' is currently in use. Retry the operation after closing the
applications.

溶液

我没有准确地跟踪这一步,但下面的评论之一最终找到了解决问题的途径。

其中一个技巧是查看进程列表,并确保在进行更新之前,所有vscode和其他powershell加载过程都已终止。

抱歉,我不能记录解决问题的确切步骤。(我在为这个干杯。)

EN

回答 2

Stack Overflow用户

发布于 2021-04-14 20:39:23

我能够通过在admin PowerShell中运行下面的命令来修复这个问题:

代码语言:javascript
复制
Update-Module -Name PowerShellGet -RequiredVersion 2.2.5

希望这能帮到别人!

来源:https://github.com/PowerShell/PowerShellGetv2/issues/599

票数 14
EN

Stack Overflow用户

发布于 2022-01-22 19:53:22

我没有代表发表评论,但詹姆斯格雷厄姆的帖子建议使用更新模块对我也有效。差不多一年后,同样的问题,同样的版本号。不过,我刚刚检查了一下,现在有了一个3.0.12测试版,需要下面的代码:

代码语言:javascript
复制
Install-Module -Name PowerShellGet -AllowPrerelease -Force

我试了一段时间想弄清楚语法的高亮显示,但没有结果。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/66305351

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档