-1

我在 Windows Server 2019 上,我无法CredentialManager使用 PowerShell 安装。

PS C:\> Install-Module CredentialManager

我收到以下错误:

PackageManagement\Install-Package : No match was found for the specified search criteria and module name 'CredentialManager'. 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

我在带有 PowerShell v5 的 Windows 2012 上使用了相同的命令,它可以工作。想法?

4

1 回答 1

-1

我在阻止这种情况的公司防火墙后面。设置代理后,我就可以安装PSGallery.

$proxyhost = "your-proxy-url.com"
$proxyport = "1234"
$proxy = "$proxyhost" + ":" + $proxyport
$proxyurl = "http://" + "$proxy"
$proxyuser = "proxy-user"
$proxypwd = "proxy-pwd

# set up proxy credentials
$secPasswd = ConvertTo-SecureString $proxypwd -AsPlainText -Force
$credential = New-Object PSCredential($proxyuser, $secPasswd)

# Set up proxy with netsh
netsh winhttp set proxy proxy-server=$proxy bypass-list=$bypassList

# Recovering the PsGallery Repository behind a Corporate Proxy
[system.net.webrequest]::defaultwebproxy = new-object system.net.webproxy($proxyurl)
[system.net.webrequest]::defaultwebproxy.credentials = $credential
[system.net.webrequest]::defaultwebproxy.BypassProxyOnLocal = $true

if(!(Get-PSRepository "PSGallery")) {
    Register-PSRepository -Name "PSGallery" –SourceLocation "https://www.powershellgallery.com/api/v2/" -InstallationPolicy Trusted
}
于 2019-06-27T15:52:12.473 回答