0

I'm on a Windows Server 2019 can I can't install the CredentialManager with PowerShell.

PS C:\> Install-Module CredentialManager

I get the following error:

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

I used the same command on Windows 2012 with PowerShell v5 and it works. Ideas?

duyn9uyen
  • 9,585
  • 12
  • 43
  • 54
  • 3
    Can you actually access the PSGallery repository? e.g. Run `Get-PSRepository` to see if it is pointed at "PSGallery". Then you can run `Find-Module -Name CredentialManager` to see if you have access – HAL9256 Jun 17 '19 at 18:02

1 Answers1

-1

I was behind a corporate firewall that was preventing this. Once I set up the the proxy, I was able to install 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
}
duyn9uyen
  • 9,585
  • 12
  • 43
  • 54