5

I try to install Powershell SQLSERVER module by executing the following command as admin (win10, 64Bit) but it fails

PS C:\WINDOWS\system32> Install-Module -Name SqlServer
PackageManagement\Install-Package : No match was found for the specified search 
criteria and module name 'SqlServer'.
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], Ex
   ception
    + FullyQualifiedErrorId : 

NoMatchFoundForCriteria,Microsoft.PowerShell.PackageManagement.Cmdlets.
InstallPackage

I have searched the web, I tried some solutions, I even talked to company admins but without luck. As they told me there is no proxy in the company, only firewall. Other colleagues can run the command without problems. The next command also fails

PS C:\WINDOWS\system32> Get-PSrepository
WARNING: Unable to find module repositories.

Any idea?

4
  • 1
    Get-PSRepository -Verbose. Also, try PowerShell -NoProfile to see if you've got something in your profile that's interfering. If all else fails, you can always try to Register-PSRepository manually (Register-PSRepository -Name PSGallery -InstallationPolicy Trusted -SourceLocation "https://www.powershellgallery.com/api/v2/" -Verbose). Commented Feb 4, 2019 at 16:45
  • thanks, I tried everything but fail. When I tried to register PSRepository, it brought back an error saying PowerShell Gallery is currently anavailable Commented Feb 4, 2019 at 16:54
  • 1
    Then it sounds like you're proxied/firewalled. Try accessing powershellgallery.com/api/v2 in your browser; if that fails you know it's not PowerShell's fault. (If that works, it can still be a firewall/anti-virus issue where PowerShell specifically has been blocked from making outgoing connections, or at least not permitted to do so.) Commented Feb 4, 2019 at 16:55
  • 1
    I can open in my browser both www.powershellgallery.com and powershellgallery.com/api/v2. Other colleagues can run all commands thus this happens only on my laptop. The -Verbose command you gave me was useful. Something is wrong with Registered repositories. Commented Feb 4, 2019 at 17:00

4 Answers 4

11

I ran into this. I had to run the following:

Register-PSRepository -Default
Register-PSRepository -Name PSGallery -InstallationPolicy Trusted -SourceLocation "https://www.powershellgallery.com/api/v2/" -Verbose

This errored out. Then I was able to run

Install-Module sqlserver
Sign up to request clarification or add additional context in comments.

2 Comments

Although I got some errors, it finally worked. thanks.
For me I had to use "Install-Module -Name SqlServer -AllowClobber" and it worked, thanks for pointing me in the right direction
7

Mine got fixed enabling tls 1.2

[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12

Comments

0

Too elaborate on @Daniel_Carlozzi answer, in an elevated PowerShell window, I ran [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 which produced no output and then Install-Module -Name SqlServer -AllowClobber which warned about a Untrusted Repository.

Comments

0

Instead of typing: Install-Module -Name SqlServer

I tried: Install-Module SqlServer

I don't know why but it worked.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.