Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Powershell install - No match was found for the specified search criteria and module name

I am having a difficult time installing/updating my powershell modules. I noticed this when I tried installing DBA Tools moudle. Reference links are https://dbatools.io/download/ and https://github.com/sqlcollaborative/dbatools.

It's a corporate PC. But I know that I have installed other modules before in the past. Does anyone have any idea what's going on?


PS (Admin)>

Install-Module DBATools

  • NOTE: The Install-Module command pauses for many minutes before the command returns a warning message.

WARNING: Unable to resolve package source 'https://www.powershellgallery.com/api/v2'. ERROR: "PackageManagement\Install-Package : No match was found for the specified search criteria and module name 'PowerShellGet'".

Update-Module PowerShellGet

ERROR: "Update-Module : Module 'PowerShellGet' was not installed by using Install-Module, so it cannot be updated.".

Update-Module PowerShellGet -Force

ERROR: "Update-Module : Module 'PowerShellGet' was not installed by using Install-Module, so it cannot be updated.".

Find-Module dbatools

  • NOTE: The Find-Module command pauses for many minutes before the command returns an error message.

ERROR: "No match was found for the specified search criteria and module name 'dbatools'. Try Get-PSRepository to see all available registered module repositories."

Get-PSRepository | fl *

Name : PSGallery

SourceLocation : https://www.powershellgallery.com/api/v2

Trusted : False

Registered : True

InstallationPolicy : Untrusted

PackageManagementProvider : NuGet

PublishLocation : https://www.powershellgallery.com/api/v2/package/

ScriptSourceLocation : https://www.powershellgallery.com/api/v2/items/psscript

ScriptPublishLocation : https://www.powershellgallery.com/api/v2/package/

ProviderOptions : {}

Get-Module PackageManagement -ListAvailable

Directory: C:\Program Files\WindowsPowerShell\Modules

ModuleType Version Name ExportedCommands

Binary 1.0.0.1 PackageManagement {Find-Package, Get-Package, Get-PackageProvider, Get-Packa...

Binary 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}}
     }

 }         

WARNING: Unable to resolve package source 'https://www.powershellgallery.com/api/v2'. WARNING: Unable to resolve package source 'https://www.powershellgallery.com/api/v2'. WARNING: Unable to resolve package source 'https://www.powershellgallery.com/api/v2'. WARNING: Unable to resolve package source 'https://www.powershellgallery.com/api/v2'. WARNING: Unable to resolve package source '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

WARNING: Unable to resolve package source 'https://www.powershellgallery.com/api/v2'.

PackageManagement\Find-Package : No match was found for the specified search criteria and module name 'dbatools'. Try Get-PSRepository to see all available registered module repositories.

Invoke-WebRequest https://www.powershellgallery.com/api/v2

Invoke-WebRequest : The underlying connection was closed: The connection was closed unexpectedly.


Some references I tried

windows 10 - Powershell won't install almost any module using install-module - Stack Overflow Powershell won't install almost any module using install-module

There's a script for that: Install-Module - unable to resolve package source 'https //www.powershellgallery.com/api/v2/' https://vanbrenk.blogspot.com/2017/09/install-module-unable-to-resolve.html

Update Manually Installed PowerShell Modules from the PowerShell Gallery – Mike F Robbins https://mikefrobbins.com/2016/06/09/update-manually-installed-powershell-modules-from-the-powershell-gallery/

Update-Module : Module 'PowershellGet' was not installed by using Install-Module, so it cannot be updated. - Evotec https://evotec.xyz/update-module-module-powershellget-was-not-installed-by-using-install-module-so-it-cannot-be-updated/

like image 681
SherlockSpreadsheets Avatar asked Aug 12 '20 22:08

SherlockSpreadsheets


People also ask

How do I install a PowerShell module?

Installing PowerShell modules from the PowerShell Gallery is the easiest way to install modules. To install a package or module from the Gallery, we use the command: Install-Module or Install-Script cmdlet, depending on the package type.

How do I install MSOnline modules?

Open an elevated Windows PowerShell command prompt (run Windows PowerShell as an administrator). Run the Install-Module MSOnline command. If you're prompted to install the NuGet provider, type Y and press Enter. If you're prompted to install the module from PSGallery, type Y and press Enter.

How do I install ad module in PowerShell?

On the Features page, expand Remote Server Administration Tools > Role Administration Tools > AD DS and AD LDS Tools, then select Active Directory module for Windows Powershell. Once selected, click Next. On the Confirmation page, click Install. Once the install completes successfully, click Close.

How do I install NuGet in PowerShell?

Open PowerShell as administrator. Run the command Install-Module PowerShellGet -Force to install the NuGet package. When asked for confirmation to install the NuGet provider, press the Y key and press Enter .


Video Answer


3 Answers

Try running Register-PSRepository -Default

like image 23
rouxquasar Avatar answered Nov 15 '22 22:11

rouxquasar


I ran into the same error installing different module. My fix was specifying TLS1.2 for the .net Security protocol.

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

like image 182
Stephen Avatar answered Nov 15 '22 23:11

Stephen


Thanks to Stephen, rouxquasar it worked with below order for me Windows 2016 Datacenter, KB4598243, Execution policy was set properly so didn't have to deal with that.

  1. Enable TLS 1.2:

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

  2. Register the default PS Gallery Repo (may check Get-PSRepository | fl* just incase)

    Register-PSRepository -Default

  3. Install-Module dbatools (check Find-Module before to validate)

Use -Force switch if an older version of dbatools exists.

like image 20
Vinay Avatar answered Nov 15 '22 22:11

Vinay