Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Powershell:无法更新PowerShellGet,错误:版本为';1.4.7';模块';包装管理';目前正在使用_Powershell - Fatal编程技术网

Powershell:无法更新PowerShellGet,错误:版本为';1.4.7';模块';包装管理';目前正在使用

Powershell:无法更新PowerShellGet,错误:版本为';1.4.7';模块';包装管理';目前正在使用,powershell,Powershell,Win10笔记本电脑,使用两年 这件事我已经坚持了好几天了 我尝试此命令: Install-Module –Name PowerShellGet –Force -AllowClobber WARNING: The version '1.4.7' of module 'PackageManagement' is currently in use. Retry the operation after closing the applications. PS C:\WINDOWS\system3

Win10笔记本电脑,使用两年

这件事我已经坚持了好几天了

我尝试此命令:

Install-Module –Name PowerShellGet –Force -AllowClobber
WARNING: The version '1.4.7' of module 'PackageManagement' 
is currently in use. Retry the operation after closing the applications.
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
引发此错误:

Install-Module –Name PowerShellGet –Force -AllowClobber
WARNING: The version '1.4.7' of module 'PackageManagement' 
is currently in use. Retry the operation after closing the applications.
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
我可以在任务管理器中看到,没有其他正在运行的powershell会话

我可以退出所有会话,并从普通cmd运行此命令:

powershell -NoProfile -Command "Install-Module -Name PowerShellGet -Force -AllowClobber"
我得到了同样的错误。

好的,我退出所有powershell实例(如taskmgr的“详细信息”选项卡中所示),然后执行以下操作:

powershell -NoProfile -Command "Uninstall-Module PowerShellGet"
powershell -NoProfile -Command "Install-Module -Name PowerShellGet -Force -AllowClobber"
我得到了同样的错误。

因此,我再次执行卸载(在没有消息或错误的情况下运行)。我把大炮拿出来。。。powershell.exe未运行,我导航到:

C:\Users\$user\Documents\WindowsPowerShell\Modules\PackageManagement\1.4.7
我删除了1.4.7目录

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

我该如何克服这一点

其他背景:

Install-Module –Name PowerShellGet –Force -AllowClobber
WARNING: The version '1.4.7' of module 'PackageManagement' 
is currently in use. Retry the operation after closing the applications.
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
也尝试过

将范围限制为当前用户:

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加载进程


抱歉,我无法记录解决问题的确切步骤。(我正在做这件事。)

我可以通过在admin PowerShell中运行下面的命令来解决这个问题:

Update-Module -Name PowerShellGet -RequiredVersion 2.2.5
希望这能帮助别人!

资料来源:《好奇》。2.2.5和1.4.7是PowerShellGet/PackageManager的当前版本。如果将
|%Path
附加到
Get Module
调用,您将看到模块清单位置。如果没有
-ListAvailable
,它将显示当前加载的版本。您可以使用
删除模块
卸载,然后加载一个您尝试更新的模块以外的模块(将完整清单路径传递给
导入模块
),然后重试。@mklement0 OP已更新路径信息,谢谢!您可以尝试在当前用户的范围内安装,并可以选择在以后手动替换“所有用户”位置中的目录。请尝试安装模块-Name powershell-get-Force-Scope CurrentUser。也就是说-看起来安装的版本已经是最新版本了。@mklement0谢谢!试过了。得到同样的警告。OP已更新(请参阅OP的底部)。我想我现在要放弃这个了;以下是官方说明,说明您应该首先运行
Install PackageProvider-Name NuGet-Force
:-它还显示了通过
Save Module
手动安装的方法。