question

MartinKovac-8642 avatar image
0 Votes"
MartinKovac-8642 asked mouadcherkaoui answered

Unable to install module from repository

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-server-powershell
repository.png (383.1 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

IanXue-MSFT avatar image
0 Votes"
IanXue-MSFT answered IanXue-MSFT commented

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.

· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

 PS C:\Windows\system32>  $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
 Register-PSRepository : Use 'Register-PSRepository -Default' to register the PSGallery repository.
 At line:9 char:2
 +  Register-PSRepository @parameters
 +  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     + CategoryInfo          : InvalidArgument: (PSGallery:String) [Register-PSRepository], ArgumentException
     + FullyQualifiedErrorId : UseDefaultParameterSetOnRegisterPSRepository,Register-PSRepository
0 Votes 0 ·

What about the solution suggested by RamonBertrand from this link
https://github.com/OneGet/oneget/issues/390

0 Votes 0 ·
MartinKovac-8642 avatar image
0 Votes"
MartinKovac-8642 answered

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> 
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

MartinKovac-8642 avatar image
0 Votes"
MartinKovac-8642 answered MartinKovac-8642 published

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
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

MartinKovac-8642 avatar image
0 Votes"
MartinKovac-8642 answered

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.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

mouadcherkaoui avatar image
0 Votes"
mouadcherkaoui answered

Hi,

try using:
Register-PSRepository -Default

it will simply register the PSGalery.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.