powershell - 注册 PSRepository 和安装 VMWare PowerCLI 模块的问题

标签 powershell vmware powercli

我的设置:Windows 10.17134、PowerShell 5.1.17134.407

当尝试使用下面的代码注册新的 PSRepository 时......

Register-PSRepository -Name "PSGallery" –SourceLocation "https://www.powershellgallery.com/api/v2/" -InstallationPolicy Trusted

...它给了我以下错误:

FullyQualifiedErrorId : UseDefaultParameterSetOnRegisterPSRepository,Register-PSRepository

我无法使用此命令安装 VMWare PowerCLI 模块:

Save-module -Name vmware.powercli -path c:\temp

….它给了我这个错误:

FullyQualifiedErrorId : NoMatchFoundForCriteria,Microsoft.PowerShell.PackageManagement.Cmdlets.SavePackage

enter image description here

最佳答案

这是一天的谷歌搜索结果

我正在运行

注册-PSRepository -名称“PSGallery” –来源位置“https://www.powershellgallery.com/api/v2/” -InstallationPolicy 受信任

(为了清晰起见,多行)

我不断得到

Register-PSRepository : Use 'Register-PSRepository -Default' to register the PSGallery repository. At line:1 char:1 + Register-PSRepository -Name "PSGallery" –SourceLocation "https://www. ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidArgument: (PSGallery:String) [Register-PSRepository], ArgumentException + FullyQualifiedErrorId : UseDefaultParameterSetOnRegisterPSRepository,Register-PSRepository

我认为这与代理设置有关,因此我尝试了在 powershell 中设置代理的所有各种方法均无济于事。

我终于跑了

获取 PSRepository

发现存储库已经注册,只是不受信任

所以我跑了

Set-PSRepository -Name PSGallery -InstallationPolicy Trusted

我这样做的最初原因是因为当我运行时

Install-PackageProvider -Name NuGet -Force -Scope CurrentUser

我明白了

Install-PackageProvider : No match was found for the specified search criteria for the provider 'NuGet'. The package provider requires 'PackageManagement' and 'Provider' tags. Please check if the specified package has the tags. At line:1 char:1 + Install-PackageProvider -Name NuGet -Force -Scope CurrentUser + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidArgument: (Microsoft.PowerShel\u2026tallPackageProvider:InstallPackageProvider) [Install-PackageProvider], Exception + FullyQualifiedErrorId : NoMatchFoundForProvider,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackageProvider

不幸的是,使存储库受信任并不能解决我的问题

...这样做的最初原因是为了我可以运行

Install-Module -Name SqlServer -Force -Verbose -Scope CurrentUser

失败了(抱歉没有错误消息,那是很久以前的事了)

然而,经过我的摆弄,这个语句现在可以正常工作了。

不确定是否是所有代理配置,或使 NuGet 受信任,或两者兼而有之

关于powershell - 注册 PSRepository 和安装 VMWare PowerCLI 模块的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54881437/

相关文章:

centos - SRAT :Hotplug area too small

powershell - 让 psessions 为 txt 文件中列出的多个服务器正确循环时出现问题

powershell - 如何在powershell中找到对象的 'sub properties'?

powershell - PowerShell 中 "| foreach { "$ _"}"的别名

powershell - PowerShell 中名称中带有点 (.) 的环境变量

linux - 主机 SMBus Controller 未启用

vmware - 如何将虚拟机从 VMWare 移植到 VirtualBox?

powershell - PowerCLI 变量的奇怪行为

azure - 导出 CSV 显示 Azure 标记的 System.Collections.Generic.Dictionary`2[System.String,System.String]?

function - Powershell - 如何构建一个函数来用其他字符替换某些特殊字符