Menu

Virtual Geek

Tales from real IT system administrators world and non-production environment

Get-PSRepository WARNING Unable to find module repositories

I was at one of my client's location and setting up PowerShell enviroment. I was trying to download few PowerShell modules from online PSGallery with below commands, while received the errors. After trying find and install PowerShell module with required parameters, in both the error outputs it was asking to run cmdlet Get-PSRepository

Find-Module Posh-SSH
PackageManagement\Find-Package : No match was found for the specified search criteria and module name 'Posh-SSH'. Try Get-PSRepository to see all available registered module repositories.
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1:1360 char:3
+         PackageManagement\Find-Package @PSBoundParameters | Microsoft ...
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Microsoft.Power...ets.FindPackage:FindPackage) [Find-Package], Exception
    + FullyQualifiedErrorId : NoMatchFoundForCriteria,Microsoft.PowerShell.PackageManagement.Cmdlets.FindPackage

Install-Module Posh-SSH -Scope CurrentUser
PackageManagement\Install-Package : No match was found for the specified search criteria and module name 'Posh-SSH'. Try Get-PSRepository to see all available registered module repositories.
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1:1772 char:21
+ ...          $null = PackageManagement\Install-Package @PSBoundParameters
+                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Microsoft.Power....InstallPackage:InstallPackage) [Install-Package], Exception
    + FullyQualifiedErrorId : NoMatchFoundForCriteria,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackage

Related Articles
Invoke-WebRequest : The underlying connection was closed: An unexpected error occurred on a send
Creating an internal PowerShell module repository
How to sign PowerShell ps1 scripts

Microsoft powershell windows server find-module posh-ssh install-module -scope currentuser packagemangement install-pacakge no match was found for specified search criteria and module get-psrepository.png

After running the cmdlet Get-PSRepository it was continually showing error WARNING: Unable to find module repositories. I have faced this issue many times in the past, This is basically due to absense of internet and PSRepository information doesn't exists.

Powershell Get-PSRepository warning unable to find module repositories unable to download the lis tof available providers, check your internet connection msg unable to download.png

Get-PSRepository
WARNING: MSG:UnableToDownload «https://go.microsoft.com/fwlink/?LinkID=627338&clcid=0x409» «»
WARNING: Unable to download the list of available providers. Check your internet connection.
WARNING: Unable to find module repositories.

As the environment was isolated and no direct internet was available on the machine. Proxy server was configured and available for internet, I configured it quickly on Internet Explorer >> Settings >> Internet Options >> Connections >> LAN settings >> Proxy server address and Port

microsoft windows powershell connections local area network lan settings use a proxy server get-psrepository internet options find-module psgallery register-psrepository.png

Now internet proxy is configured on the machine, by running below command, It was again showing me long error messages with crux of unable to connect internet connection. This was happening due to some OS hardening done on the operating system, Powershell console was not able to connect to internet through system IE proxy.

Register-PSRepository -Default

NuGet provider is required to continue
PowerShellGet requires NuGet provider version '2.8.5.201' or newer to interact with NuGet-based repositories. The NuGet provider must be available in 'C:\Program Files\PackageManagement\ProviderAssemblies' or 'C:\Users\vkunal.VCLOUD-LAB\AppData\Local\PackageManagement\ProviderAssemblies'. You can also install the NuGet provider by running 'Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force'. Do you want PowerShellGet to install and import the NuGet provider now?
[Y] Yes  [N] No  [S] Suspend  [?] Help (default is "Y"): Y
WARNING: Unable to download from URI 'https://go.microsoft.com/fwlink/?LinkID=627338&clcid=0x409' to ''.
WARNING: Unable to download the list of available providers. Check your internet connection.
PackageManagement\Install-PackageProvider : No match was found for the specified search criteria for the provider 'NuGet'. The package provider requires 'PackageManagement' and 'Provider' tags. Please check if the specified package has the tags.
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1:7405 char:21
+ ...     $null = PackageManagement\Install-PackageProvider -Name $script:N ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (Microsoft.Power...PackageProvider:InstallPackageProvider) [Install-PackageProvider], Exception
    + FullyQualifiedErrorId : NoMatchFoundForProvider,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackageProvider

PackageManagement\Import-PackageProvider : No match was found for the specified search criteria and provider name 'NuGet'. Try 'Get-PackageProvider -ListAvailable' to see if the provider exists on the system.
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1:7411 char:21
+ ...     $null = PackageManagement\Import-PackageProvider -Name $script:Nu ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (NuGet:String) [Import-PackageProvider], Exception
    + FullyQualifiedErrorId : NoMatchFoundForCriteria,Microsoft.PowerShell.PackageManagement.Cmdlets.ImportPackageProvider

WARNING: Unable to download from URI 'https://go.microsoft.com/fwlink/?LinkID=627338&clcid=0x409' to ''.
WARNING: Unable to download the list of available providers. Check your internet connection.
PackageManagement\Get-PackageProvider : Unable to find package provider 'NuGet'. It may not be imported yet. Try 'Get-PackageProvider -ListAvailable'.
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1:7415 char:30
+ ... tProvider = PackageManagement\Get-PackageProvider -Name $script:NuGet ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Microsoft.Power...PackageProvider:GetPackageProvider) [Get-PackageProvider], Exception
    + FullyQualifiedErrorId : UnknownProviderFromActivatedList,Microsoft.PowerShell.PackageManagement.Cmdlets.GetPackageProvider

Register-PSRepository : NuGet provider is required to interact with NuGet-based repositories. Please ensure that '2.8.5.201' or newer version of NuGet provider is installed.
At line:1 char:1
+ Register-PSRepository -Default
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [Register-PSRepository], InvalidOperationException
    + FullyQualifiedErrorId : CouldNotInstallNuGetProvider,Register-PSRepository

microsoft powershell register-psrepository -default get-psrepository nuget provider is required to continue powershellget requires nuget provider version or newer to interact with nuget-based repositories.png

To tackle this issue I used Proxy parameter with proxy address and port for registering default psrepository and it worked very well. (You can use -proxycredential parameter additionally for username and password). Now I can test default online psgallery repo with Get-PSRepository, which shows PSGallery is added successfully with url. 

Register-PSRepository -Default -Proxy 'http://192.168.34.102:808'

NuGet provider is required to continue
PowerShellGet requires NuGet provider version '2.8.5.201' or newer to interact with NuGet-based repositories. The NuGet provider must be available in 'C:\Program Files\PackageManagement\ProviderAssemblies' or 'C:\Users\vkunal.VCLOUD-LAB\AppData\Local\PackageManagement\ProviderAssemblies'. You can also install the NuGet provider by running 'Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force'. Do you want PowerShellGet to install and import the NuGet provider now?
[Y] Yes  [N] No  [S] Suspend  [?] Help (default is "Y"): Y

Get-PSRepository

Name                      InstallationPolicy   SourceLocation
----                      ------------------   --------------
PSGallery                 Untrusted            https://www.powershellgallery.com/api/v2

Microsoft powershell register-psrepository get-psrepository install-module find-module you can also install the nuget provider by running install-packageprovider -name nuget -minimumVersion -force import nuget provider.png

Now I can find, Install and check if PowerShell module can be downloaded from online PSGallery and imported successfully as below commands.

Find-Module Posh-SSH -Proxy 'http://192.168.34.102:808'

Version    Name                                Repository           Description
-------    ----                                ----------           -----------
2.2        Posh-SSH                            PSGallery            Provide SSH and SCP functionality for executing ...

Install-Module Posh-SSH -Proxy 'http://192.168.34.102:808' -Scope CurrentUser

Untrusted repository
You are installing the modules from an untrusted repository. If you trust this repository, change its InstallationPolicy value by running the Set-PSRepository cmdlet. Are you sure you want to install the modules from 'PSGallery'?
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "N"): Y

Get-Module -ListAvailable | Where-Object {$_.Name -eq 'Posh-SSH'}

    Directory: C:\Users\vkunal.VCLOUD-LAB\Documents\WindowsPowerShell\Modules

ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Manifest   2.2        Posh-SSH                            {Get-SCPFile, Get-SCPFolder, Get-SCPItem, Get-SFTPFile...}

Microsoft powershell find module -proxy install-module -scope currentUser get-module -listavailable where-object untrusted repository, trust repository change its installationpolicy value set-psrepository psgallery.png

Useful Articles
GUI - SETUP AND CONFIGURE POWERSHELL WEB ACCESS SERVER (GATEWAY)
USE POWERSHELL ON MOBILE - SETUP AND CONFIGURE POWERSHELL WEB ACCESS (PSWA) 
Different ways to bypass Powershell execution policy :.ps1 cannot be loaded because running scripts is disabled
Powershell Trick : Execute or run any file as a script file
Set Powershell execution policy with Group Policy
Powershell execution policy setting is overridden by a policy defined at a more specific scope

Go Back



Comment

Blog Search

Page Views

12278968

Follow me on Blogarama