Problem using Artifactory to mirror PowerShellGallery.com

I am trying to use Artifactory as a mirror for approved PowerShell modules hosted on PowerShellGallery.com. The connection from Artifactory to PowerShellGallery.com appears to be working, but I have been unable to get PowerShell clients to connect to the internal nuget repo. The URL I am using exactly matches the one Artifactory instructs to use, but PowerShell throws ‘Repository location is not valid for this provider’ and ‘Unable to resolve module repository “(Artifactory URL)/api/nuget/vnuget”’ warnings when I try to register it or subsequently run the ‘Find-Module’ cmdlet.

At the end of the day I’m expecting that I can…

  1. Use PowerShell 5.0, 5.1, 6.0 to connect to the internal Artifactory NuGet repo
  2. When connecting, PowerShellGet and/or NuGet will automatically install or update as needed.
    a. Is PackageManagement the same as NuGet? My expectation is that ‘nuget-anycpu.exe’ installs as part of PackageMangement.

https://gist.github.com/JMGEHMAN/f57cc850147078a4c4e06ed4957c27cc

I also sometimes receive an error message stating “The specified Uri ‘(Artifactory URL)/api/nuget/vnuget’ for parameter ‘SourceLocation’ is an invalid Web Uri. Please ensure that it meets the Web Uri requirements.”.

Looks like our .NET security protocol settings differ from what our Artifactory is using. I found (https://johnlouros.com/blog/enabling-strong-cryptography-for-all-dot-net-applications) which looks like the right way to configure .NET settings, which is what PowerShell is pulling from.

Adding all security protocols:

$AllProtocols = [System.Net.SecurityProtocolType]'Ssl3,Tls,Tls11,Tls12'
[System.Net.ServicePointManager]::SecurityProtocol = $AllProtocols