无法在Powershell 5中安装CredentialManager模块

时间:2019-06-17 17:05:37

标签: windows powershell credential-manager

我在Windows Server 2019上,无法使用PowerShell安装html, body{ height: 100vh; margin: 0px; } app-root { display: block; height: 100%; }

CredentialManager

我收到以下错误:

PS C:\> Install-Module CredentialManager

我在Windows 2012和PowerShell v5上使用了相同的命令,并且可以正常工作。想法?

1 个答案:

答案 0 :(得分:-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
}