无法在Powershell中安装SQLServer模块

时间:2019-02-04 16:41:53

标签: sql-server powershell sqlps

我尝试通过以admin(win10,64位)身份执行以下命令来安装Powershell SQLSERVER模块,但失败了

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

我搜索了网络,尝试了一些解决方案,甚至与公司管理员进行了交谈,但都没有走运。正如他们告诉我的那样,公司中没有代理,只有防火墙。其他同事可以毫无问题地运行命令。下一条命令也会失败

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

有什么主意吗?

2 个答案:

答案 0 :(得分:1)

我遇到了这个。我必须运行以下命令:

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

这个错误了。然后我就可以跑步

Install-Module sqlserver

答案 1 :(得分:0)

我的固定启用了tls 1.2

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