AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / user-48213

phantom-99w's questions

Martin Hope
phantom-99w
Asked: 2025-03-05 16:07:43 +0800 CST

如何在公司防火墙后面升级 PowerShellGet?

  • 6

我正在尝试在 Windows Server 2019 上将 PowerShellGet 从 1.0.0.1 版本升级到较新版本。我不是 NuGet 专家,但对包提供程序和包源有基本的了解。我一直在遵循Microsoft Learn 网站上的这个指南和这个指南以及其他指南。我位于公司防火墙后面,无法访问常规互联网。我们有一个Nexus实例,其中配置了以下存储库:

  • Nuget 代理名为 psgallery-proxy,网址为https://www.powershellgallery.com/api/v2/
  • Nuget 代理名为 nugetorg-proxy,网址为https://www.nuget.org/api/v2/

首先,我将 NuGet 提供程序版本 2.8.5.208 从另一台计算机复制到$env:ProgramFiles\PackageManagement\ProviderAssemblies\NuGet\2.8.5.208。然后在 Powershell 中执行了以下步骤:

[Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12
Import-PackageProvider -Name NuGet -RequiredVersion 2.8.5.208
$cred = Get-Credential
Register-PackageSource -Name NexusNugetOrg -ProviderName Nuget -Location https://example.com/repository/nugetorg-proxy/ -Trusted -Credential $cred
Register-PSRepository -Name NexusPSGallery -SourceLocation https://example.com/repository/psgallery-proxy/ -InstallationPolicy Trusted -Credential $cred

运行这些命令后,我得到以下内容,在我看来这是正确的:

PS C:\Windows\system32> Get-PackageProvider -ListAvailable

Name                     Version          DynamicOptions
----                     -------          --------------
msi                      3.0.0.0          AdditionalArguments
msu                      3.0.0.0
NuGet                    2.8.5.208        Destination, ExcludeVersion, Scope, SkipDependencies, Headers, FilterOnTag, Contains, AllowPrereleaseVersions, ConfigFile, SkipValidate
PowerShellGet            1.0.0.1          PackageManagementProvider, Type, Scope, AllowClobber, SkipPublisherCheck, InstallUpdate, NoPathUpdate, Filter, Tag, Includes, DscResource, RoleCapability, Command, PublishLocation, ScriptSourceLocation, ScriptPublishLocation
Programs                 3.0.0.0          IncludeWindowsInstaller, IncludeSystemComponent
 

PS C:\Windows\system32> Get-PackageSource

Name                             ProviderName     IsTrusted  Location
----                             ------------     ---------  --------
NexusNugetOrg                    NuGet            True       https://example.com/repository/nugetorg-proxy/
NexusPSGallery                   PowerShellGet    True       https://example.com/repository/psgallery-proxy/

PS C:\Windows\system32> (Get-ItemPropertyValue -LiteralPath 'HKLM:SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full' -Name Release) -ge 394802
True

我可以安装普通软件包。如果我运行以下命令,模块安装成功,并且我可以dbatools在 Nexus 中看到它:

Install-Module -Name dbatools -Force -Credential $cred -Repository NexusPSGallery

但是,我无法升级 PowerShellGet。我得到以下输出:

PS C:\Windows\system32> Install-Module -Name PowerShellGet -Force -AllowClobber -Credential $cred -Repository NexusNugetOrg
PackageManagement\Get-PackageSource : Unable to find repository 'NexusNugetOrg'. Use Get-PSRepository to see all available repositories.
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1:4489 char:35
+ ... ckageSources = PackageManagement\Get-PackageSource @PSBoundParameters
+                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Microsoft.Power...etPackageSource:GetPackageSource) [Get-PackageSource], Exception
    + FullyQualifiedErrorId : SourceNotFound,Microsoft.PowerShell.PackageManagement.Cmdlets.GetPackageSource
 
PS C:\Windows\system32> Install-Module -Name PowerShellGet -Force -AllowClobber -Credential $cred -Repository NexusPSGallery
PackageManagement\Install-Package : No match was found for the specified search criteria and module name 'PowerShellGet'. Try Get-PSRepository to see all available registered module repositories.
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1:1809 char:21
+ ...          $null = PackageManagement\Install-Package @PSBoundParameters
+                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Microsoft.Power....InstallPackage:InstallPackage) [Install-Package], Exception
    + FullyQualifiedErrorId : NoMatchFoundForCriteria,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackage

我缺少什么才能成功运行 Install-Module PowerShellGet?

windows
  • 1 个回答
  • 78 Views

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve