powershell - 为什么 PowerShell 5 在重命名后仍在寻找旧的 PowerShell Gallery 路径?

标签 powershell

我有一个本地 PowerShell 库,我将其重命名为 JnPSGallery。
我注销了旧路径 \\\Ryzen\G$\JnPowerShellGallery然后注册新路径\\\Ryzen\G$\JnPSGallery ,但是当我使用 Update-Module 命令时,PowerShell 5 仍在尝试查找旧路径。我什至尝试注销所有存储库,然后输入 Update-Module 以查看会发生什么。

我收到错误“PackageManagement\Install-Package : Unable to find repository \\\Ryzen\G$\JnPowerShellGallery .使用Get-PSRepository查看所有可用的存储库。即使所有存储库都未注册,它仍在寻找旧的 PowerShell 库路径。

注册新的 JnPSGallery 路径后更新模块。
https://i.imgur.com/SOgk3zn.png

删除所有已注册的存储库后更新模块。
https://i.imgur.com/ZFTi0ut.png

如何阻止 PowerShell 5 尝试使用旧路径 \\\Ryzen\G$\JnPowerShellGallery ?

最佳答案

感谢您的帮助乔尔和阿德里安安德森。我解决了我的问题!

乔尔在 http://slack.poshcode.org/ powershell-help channel 建议我安装的一些模块可能仍在引用我的旧 PSGallery 路径。他是对的!

当我今天早上醒来时,我打开了 PowerShell 5,输入了 Get-InstalledModule,就在我面前的是仍然引用我的旧 PSGallery 路径的两个模块。我卸载了这些模块,错误就消失了。

我原本以为问题出在 PowerShellGet 模块上。我现在觉得很傻。

Get-InstalledModule 显示两个引用旧库的模块。
https://i.imgur.com/TWFtWcP.png

感谢 Joel,它使我免于重新安装 Windows。

关于powershell - 为什么 PowerShell 5 在重命名后仍在寻找旧的 PowerShell Gallery 路径?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58348897/

相关文章:

powershell - 如何将特定文件制作为零字节文件

powershell - 传递给 Invoke-Command 的属性将类型从 IDictionary 更改为 HashTable

powershell - IIS配置可以同时修改吗

powershell - 如何使用Powershell对Excel列进行排序

powershell - 32 内部错误 "A device attached to the system is not functioning"设置控制台窗口标题时发生 0x1F

powershell - 添加错误以从 VSTS 中运行的 PowerShell 脚本构建摘要

Powershell、文件系统提供程序、Get-ChildItem 过滤……官方文档在哪里?

Powershell:由于向前和向后兼容性,ConvertFrom-Json 没有获得分配的变量

powershell - PowerShell 中 Power BI Rest API 的错误处理

powershell - 如何传递开关变量?