当执行Install-Module命令时报错:找不到与指定的搜索条件和程序包名称匹配的项目,请尝试使用Get-PSRepository查看所有可用的注册程序包源
解决方案:
Get-PSRepository
查看包源为空,然后执行
Register-PSRepository -Default
然后再执行Get-PSRepository就有包源了
然后就可以执行Install-Module继续安装了,以安装DotNetVersionLister为例
Register-PSRepository -Default 2>&1 > $null
Get-PSRepository 2>&1 > $null
(Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full").Release
[System.Net.ServicePointManager]::SecurityProtocol.HasFlag([Net.SecurityProtocolType]::Tls12)
if(([System.Net.ServicePointManager]::SecurityProtocol.HasFlag([Net.SecurityProtocolType]::Tls12)) -eq $false){
[Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12
}
[System.Net.ServicePointManager]::SecurityProtocol.HasFlag([Net.SecurityProtocolType]::Tls12)
Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force 2>&1 > $null
Install-Module -Name DotNetVersionLister -Scope CurrentUser -Force 2>&1 > $null
#Get-STDotNetVersion -NoSummary 2>&1 > $null
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。