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:

Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
$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.

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
						

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> 
						

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
						

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.