我很难安装/更新我的 powershell 模块。我在尝试安装 DBA Tools moudle 时注意到了这一点。引用链接是 https://dbatools.io/download/和 https://github.com/sqlcollaborative/dbatools .
这是一台公司PC。但我知道我以前安装过其他模块。有谁知道发生了什么?
PS(管理员)> Install-Module DBATools
警告:无法解析包源“https://www.powershellgallery.com/api/v2”。
错误:“PackageManagement\Install-Package:未找到指定搜索条件和模块名称‘PowerShellGet’的匹配项”。
Update-Module PowerShellGet
错误:“更新模块:模块 'PowerShellGet' 未使用安装模块安装,因此无法更新。”。Update-Module PowerShellGet -Force
错误:“更新模块:模块 'PowerShellGet' 未使用安装模块安装,因此无法更新。”。Find-Module dbatools
错误:“未找到指定搜索条件和模块名称‘dbatools’的匹配项。尝试 Get-PSRepository 以查看所有可用的已注册模块存储库。”
Get-PSRepository | fl *
名称:PSGallery来源位置:https://www.powershellgallery.com/api/v2
可信:错误
已注册:真
InstallationPolicy:不受信任
包管理提供者:NuGet
发布位置:https://www.powershellgallery.com/api/v2/package/
脚本来源位置:https://www.powershellgallery.com/api/v2/items/psscript
脚本发布位置:https://www.powershellgallery.com/api/v2/package/
提供者选项:{}
Get-Module PackageManagement -ListAvailable
目录:C:\Program Files\WindowsPowerShell\ModulesModuleType 版本名称 ExportedCommands
二进制 1.0.0.1 PackageManagement {Find-Package、Get-Package、Get-PackageProvider、Get-Packa...
二进制 1.0.0.1 PackageManagement {Find-Package、Get-Package、Get-PackageProvider、Get-Packa...
Get-Module -ListAvailable |
Where-Object ModuleBase -like $env:ProgramFiles\WindowsPowerShell\Modules\* |
Sort-Object -Property Name, Version -Descending |
Get-Unique -PipelineVariable Module |
ForEach-Object {
if (-not(Test-Path -Path "$($_.ModuleBase)\PSGetModuleInfo.xml")) {
Find-Module -Name $_.Name -OutVariable Repo -ErrorAction SilentlyContinue |
Compare-Object -ReferenceObject $_ -Property Name, Version |
Where-Object SideIndicator -eq '=>' |
Select-Object -Property Name,
Version,
@{label='Repository';expression={$Repo.Repository}},
@{label='InstalledVersion';expression={$Module.Version}}
}
}
警告:无法解析包源“https://www.powershellgallery.com/api/v2”。警告:无法解析包源“https://www.powershellgallery.com/api/v2”。
警告:无法解析包源“https://www.powershellgallery.com/api/v2”。
警告:无法解析包源“https://www.powershellgallery.com/api/v2”。
警告:无法解析包源“https://www.powershellgallery.com/api/v2”。
$webclient=New-Object System.Net.WebClient
$webclient.Proxy.Credentials = [System.Net.CredentialCache]::DefaultNetworkCredentials
[Net.ServicePointManager]::SecurityProtocol = "tls12"
Find-Module dbatools
警告:无法解析包源“https://www.powershellgallery.com/api/v2”。PackageManagement\Find-Package :未找到指定搜索条件和模块名称“dbatools”的匹配项。尝试
Get-PSRepository 以查看所有可用的已注册模块存储库。
Invoke-WebRequest https://www.powershellgallery.com/api/v2
Invoke-WebRequest :底层连接已关闭:连接意外关闭。我试过的一些引用资料
windows 10 - Powershell几乎不会使用install-module安装任何模块 - Thinbug
Powershell won't install almost any module using install-module
有一个脚本:安装模块 - 无法解析包源'https//www.powershellgallery.com/api/v2/'
https://vanbrenk.blogspot.com/2017/09/install-module-unable-to-resolve.html
从 PowerShell 库更新手动安装的 PowerShell 模块 – Mike F Robbins
https://mikefrobbins.com/2016/06/09/update-manually-installed-powershell-modules-from-the-powershell-gallery/
Update-Module:模块“PowershellGet”没有使用 Install-Module 安装,因此无法更新。 - Evotec
https://evotec.xyz/update-module-module-powershellget-was-not-installed-by-using-install-module-so-it-cannot-be-updated/
最佳答案
我在安装不同的模块时遇到了同样的错误。我的解决方法是为 .net 安全协议(protocol)指定 TLS1.2。
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
关于Powershell 安装 - 未找到指定搜索条件和模块名称的匹配项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63385304/