无法在 Powershell 中安装 SQLServer 模块

use*_*479 3 sql-server powershell sqlps

我尝试通过以管理员身份(win10,64Bit)执行以下命令来安装 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
Run Code Online (Sandbox Code Playgroud)

我在网上搜索过,尝试了一些解决方案,我什至与公司管理员交谈过,但没有运气。正如他们告诉我的那样,公司没有代理,只有防火墙。其他同事可以毫无问题地运行该命令。下一个命令也失败

PS C:\WINDOWS\system32> Get-PSrepository
WARNING: Unable to find module repositories.
Run Code Online (Sandbox Code Playgroud)

任何的想法?

小智 10

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

Register-PSRepository -Default
Register-PSRepository -Name PSGallery -InstallationPolicy Trusted -SourceLocation "https://www.powershellgallery.com/api/v2/" -Verbose
Run Code Online (Sandbox Code Playgroud)

这出错了。然后我就可以跑了

Install-Module sqlserver
Run Code Online (Sandbox Code Playgroud)


小智 7

我的已修复,启用 tls 1.2

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