AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • Início
  • system&network
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • Início
  • system&network
    • Recentes
    • Highest score
    • tags
  • Ubuntu
    • Recentes
    • Highest score
    • tags
  • Unix
    • Recentes
    • tags
  • DBA
    • Recentes
    • tags
  • Computer
    • Recentes
    • tags
  • Coding
    • Recentes
    • tags
Início / user-48213

phantom-99w's questions

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

Como faço para atualizar o PowerShell para ficar atrás de um firewall corporativo?

  • 6

Estou tentando atualizar o PowerShellGet da versão 1.0.0.1 para uma versão mais recente no Windows Server 2019. Não sou especialista em NuGet, mas tenho um conhecimento básico de provedores e fontes de pacotes. Tenho seguido este e este guia no site Microsoft Learn, além de outros. Estou protegido por um firewall corporativo e não consigo acessar a internet em geral. Temos uma instância do Nexus com os seguintes repositórios configurados:

  • Proxy NuGet chamado psgallery-proxy de https://www.powershellgallery.com/api/v2/
  • Proxy NuGet chamado nugetorg-proxy de https://www.nuget.org/api/v2/

Primeiro, copiei a versão 2.8.5.208 do provedor NuGet de outro computador para o $env:ProgramFiles\PackageManagement\ProviderAssemblies\NuGet\2.8.5.208. Depois, executei os seguintes passos no 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

Depois de executar esses comandos, recebo o seguinte, que me parece estar correto:

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

Consigo instalar pacotes normais. Se eu executar o seguinte comando, a instalação do módulo será bem-sucedida e posso ver que ele dbatoolsaparece no Nexus:

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

No entanto, não consigo atualizar o PowerShellGet. Recebo a seguinte saída:

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

O que estou perdendo para conseguir executar com sucesso o Install-Module PowerShellGet?

windows
  • 1 respostas
  • 78 Views

Sidebar

Stats

  • Perguntas 205573
  • respostas 270741
  • best respostas 135370
  • utilizador 68524
  • Highest score
  • respostas
  • Marko Smith

    Você pode passar usuário/passar para autenticação básica HTTP em parâmetros de URL?

    • 5 respostas
  • Marko Smith

    Ping uma porta específica

    • 18 respostas
  • Marko Smith

    Verifique se a porta está aberta ou fechada em um servidor Linux?

    • 7 respostas
  • Marko Smith

    Como automatizar o login SSH com senha?

    • 10 respostas
  • Marko Smith

    Como posso dizer ao Git para Windows onde encontrar minha chave RSA privada?

    • 30 respostas
  • Marko Smith

    Qual é o nome de usuário/senha de superusuário padrão para postgres após uma nova instalação?

    • 5 respostas
  • Marko Smith

    Qual porta o SFTP usa?

    • 6 respostas
  • Marko Smith

    Linha de comando para listar usuários em um grupo do Windows Active Directory?

    • 9 respostas
  • Marko Smith

    O que é um arquivo Pem e como ele difere de outros formatos de arquivo de chave gerada pelo OpenSSL?

    • 3 respostas
  • Marko Smith

    Como determinar se uma variável bash está vazia?

    • 15 respostas
  • Martin Hope
    Davie Ping uma porta específica 2009-10-09 01:57:50 +0800 CST
  • Martin Hope
    kernel O scp pode copiar diretórios recursivamente? 2011-04-29 20:24:45 +0800 CST
  • Martin Hope
    Robert ssh retorna "Proprietário incorreto ou permissões em ~/.ssh/config" 2011-03-30 10:15:48 +0800 CST
  • Martin Hope
    Eonil Como automatizar o login SSH com senha? 2011-03-02 03:07:12 +0800 CST
  • Martin Hope
    gunwin Como lidar com um servidor comprometido? 2011-01-03 13:31:27 +0800 CST
  • Martin Hope
    Tom Feiner Como posso classificar a saída du -h por tamanho 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich O que é um arquivo Pem e como ele difere de outros formatos de arquivo de chave gerada pelo OpenSSL? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent Como determinar se uma variável bash está vazia? 2009-05-13 09:54:48 +0800 CST

Hot tag

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

Explore

  • Início
  • Perguntas
    • Recentes
    • Highest score
  • tag
  • help

Footer

AskOverflow.Dev

About Us

  • About Us
  • Contact Us

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve