Unable to install module from repository

Martin Kováč 1 Reputation point
2021-04-23T07:34:21.517+00:00

Hello,

I have an issue with installing new module on windows 2016.

What I already found and applied:

[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12  
  
[system.net.webrequest]::defaultwebproxy = new-object system.net.webproxy('http://proxyXXXXXXX.com:8080')  
[system.net.webrequest]::defaultwebproxy.credentials =  [System.Net.CredentialCache]::DefaultNetworkCredentials  
[system.net.webrequest]::defaultwebproxy.BypassProxyOnLocal = $true  

Set-ItemProperty -Path 'HKLM:\SOFTWARE\Wow6432Node\Microsoft\.NetFramework\v4.0.30319' -Name 'SchUseStrongCrypto' -Value '1' -Type DWord  
set strong cryptography on 32 bit .Net Framework (version 4 and above)  
Set-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\.NetFramework\v4.0.30319' -Name 'SchUseStrongCrypto' -Value '1' -Type DWord  

Nothing helps I still don't see the repository set:

90664-repository.png

Windows for business | Windows Server | User experience | PowerShell
0 comments No comments
{count} votes

6 answers

Sort by: Most helpful
  1. AbdulQadir Kola-Olukotun 11 Reputation points
    2022-12-27T17:10:09.297+00:00

    After several attempts to resolve the issue using various commands all to no avail, I exited the powershell session and closed the terminal. I then

    1. restarted the terminal,
    2. started powershell,
    3. ran [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
    4. then attempted the installation again ( Install-Module -Name Az -Scope CurrentUser -Repository PSGallery -Force )and it came up successful.

    Many thanks for all the suggestions.

    2 people found this answer helpful.
    0 comments No comments

  2. Anonymous
    2021-04-23T09:04:46.547+00:00

    Hi,

    Does this work for you?

    $parameters = @{  
      Name = "PSGallery"  
      SourceLocation = "https://www.powershellgallery.com/api/v2"  
      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/"  
      InstallationPolicy = 'Untrusted'  
    }  
    Register-PSRepository @parameters  
    

    Best Regards,
    Ian Xue

    ============================================

    If the Answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.

  3. Martin Kováč 1 Reputation point
    2021-04-28T10:40:27.947+00:00

    Closer but not too much:

    PS C:\Windows\system32> Register-PSRepository -default
    PackageManagement\Register-PackageSource : Module Repository 'PSGallery' exists.
    At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1:4173 char:17
    + ...     $null = PackageManagement\Register-PackageSource @PSBoundParamete ...
    +                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : ResourceExists: (Microsoft.Power...erPackageSource:RegisterPackageSource) [Register-PackageSource], Exception
        + FullyQualifiedErrorId : PackageSourceExists,Microsoft.PowerShell.PackageManagement.Cmdlets.RegisterPackageSource
    
    
    PS C:\Windows\system32> Get-PSRepository
    
    Name                      InstallationPolicy   SourceLocation                                                                                                                                               
    ----                      ------------------   --------------                                                                                                                                               
    PSGallery                 Untrusted            https://www.powershellgallery.com/api/v2                                                                                                                     
    
    
    
    PS C:\Windows\system32> Install-Module -Name Az -AllowClobber -Verbose:$true
    VERBOSE: Using the provider 'PowerShellGet' for searching packages.
    VERBOSE: The -Repository parameter was not specified.  PowerShellGet will use all of the registered repositories.
    VERBOSE: Getting the provider object for the PackageManagement Provider 'NuGet'.
    VERBOSE: The specified Location is 'https://www.powershellgallery.com/api/v2' and PackageManagementProvider is 'NuGet'.
    VERBOSE: An error occurred while sending the request.
    VERBOSE: Retry downloading 'https://www.powershellgallery.com/api/v2' for '2' more times
    VERBOSE: An error occurred while sending the request.
    VERBOSE: Retry downloading 'https://www.powershellgallery.com/api/v2' for '1' more times
    VERBOSE: An error occurred while sending the request.
    VERBOSE: Retry downloading 'https://www.powershellgallery.com/api/v2' for '0' more times
    WARNING: Unable to resolve package source 'https://www.powershellgallery.com/api/v2'.
    VERBOSE: Total package yield:'0' for the specified package 'Az'.
    PackageManagement\Install-Package : No match was found for the specified search criteria and module name 'Az'. 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
    
    
    PS C:\Windows\system32> 
    
    0 comments No comments

  4. Martin Kováč 1 Reputation point
    2021-04-28T10:45:01.353+00:00

    I'm able to issue a get-psrepository command without error but still not able to install the requested module.

    I've changed the $debugpreference to "Continue" and get a detailed log. I'm not sure but I think the relevant information is :

    DEBUG: 00:00:00.0707830 OPTION: Name => Az
    VERBOSE: The -Repository parameter was not specified.  PowerShellGet will use all of the registered repositories.
    VERBOSE: Getting the provider object for the PackageManagement Provider 'NuGet'.
    VERBOSE: The specified Location is 'https://www.powershellgallery.com/api/v2' and PackageManagementProvider is 'NuGet'.
    DEBUG: 00:00:00.0804809 PackageProvider::FindPackage with name Az
    DEBUG: 00:00:00.0836448 Calling 'NuGet'::'FindPackage' - name='Az', requiredVersion='',minimumVersion='', maximumVersion='''.
    DEBUG: 00:00:00.0842153 Iterating 'Az'.
    DEBUG: 00:00:00.0852100 There are '0' registered sources in 'NuGet' provider.
    DEBUG: 00:00:00.0857066 Source 'https://www.powershellgallery.com/api/v2' is not one of the registered sources in 'NuGet' provider.
    VERBOSE: An error occurred while sending the request.
    VERBOSE: Retry downloading 'https://www.powershellgallery.com/api/v2' for '2' more times
    VERBOSE: An error occurred while sending the request.
    VERBOSE: Retry downloading 'https://www.powershellgallery.com/api/v2' for '1' more times
    VERBOSE: An error occurred while sending the request.
    VERBOSE: Retry downloading 'https://www.powershellgallery.com/api/v2' for '0' more times
    WARNING: Unable to resolve package source 'https://www.powershellgallery.com/api/v2'.
    VERBOSE: Total package yield:'0' for the specified package 'Az'.
    DEBUG: 00:00:01.7105453 Completed iterating for 'Az'.
    DEBUG: 00:00:01.7116667 PowerShell Script 'PSModule' Function 'Find-Package' returns null.
    DEBUG: 00:00:01.7137400 Done calling powershell «Find-Package» «PSModule»
    DEBUG: 00:00:01.7144444 unmatched package name='Az'
    PackageManagement\Install-Package : No match was found for the specified search criteria and module name 'Az'. 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
    
    0 comments No comments

  5. Martin Kováč 1 Reputation point
    2021-04-28T10:47:08.853+00:00

    Especially in these 2 lines:
    DEBUG: 00:00:00.0852100 There are '0' registered sources in 'NuGet' provider.
    DEBUG: 00:00:00.0857066 Source 'https://www.powershellgallery.com/api/v2' is not one of the registered sources in 'NuGet' provider.

    however so far I didn't find a solution for that.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.