简体   繁体   中英

Cannot install SQLServer module in Powershell

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?

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

Mine got fixed enabling tls 1.2

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM