无法在 Powershell 5 中安装 CredentialManager 模块

Can't install CredentialManager module in Powershell 5

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

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.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

我在 Windows 2012 上用 PowerShell v5 使用了相同的命令并且它有效。想法?

我在阻止这种情况的公司防火墙后面。一旦我设置了代理,我就可以安装 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
}