I recently ran into this problem: I had to install the Azure Az PowerShell module from the PowerShell Gallery on a new computer. Interestingly the installation with
Install-Module -Name Az failed with the error message "WARNING: Source Location 'https://www.powershellgallery.com/api/v2/package/Az.Accounts/1.9.3' is not valid.". See my solution here.
The Azure Az PowerShell module provides access to the world of Azure. See more at Introducing the new Azure PowerShell Az module.
So, if you run into this issue when executing
Install-Module -Name Az -Force (see Install-Module) and you get this error message...
WARNING: Source Location 'https://www.powershellgallery.com/api/v2/package/Az.Accounts/1.9.3' is not valid.
PackageManagement\Install-Package : Package 'Az.Accounts' failed to download.
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\126.96.36.199\PSModule.psm1:1809 char:21
+ ... $null = PackageManagement\Install-Package @PSBoundParameters
+ CategoryInfo : ResourceUnavailable: (C:\Users\Martin\A....Accounts.nupkg:String) [Install-Package], Exception
+ FullyQualifiedErrorId : PackageFailedInstallOrDownload,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackage
...the installation does not work. I tested on two different machines with the same result, as the following screenshot shows.
My first investigation was about setting the transport protocol to TLS v1.2 (as you can see in the screenshot above). This still failed. The second approach, downloading the module first with Save-Module , or to update the module with Update-Module (on another computer where an older version was already installed) analogously led to the same error.
Then I found an interesting (and closed) issue on Github at Not able to install powershell az module #9940 from fall 2019. User BlairPaine wrote: "I managed to work around this issue by changing network." And that really worked! I switched from my ISP network to my phone with tethering and voila, the PowerShell module installed properly. Even though I'm not using a proxy server, switching to another network was my (temporary) solution. This is an interesting workaround that I was not aware of.
Anyway, I hope this quick tip helps, if you run into the same issue when installing a new module from the PowerShell Gallery!