Unable to find package providers (NuGet)

In this Azure tutorial, we will discuss how to fix the error, Unable to find package providers (NuGet), which comes while trying to install the PowerShell Nuget and Azure PowerShell module using PowerShell ISE.

Unable to find package providers (NuGet)

Recently, while I was trying to install PowerShell NuGet, I got this error. I was executing the PowerShell script to install PowerShell NuGet and got this error.

When I tried to install the ‘Nuget’ package using the PowerShell cmdlet below, I got the above error.

I was executing the following line of code to install NuGet PowerShell.

$_nugetUrl = "https://api.nuget.org/v3/index.json" 
$MypS = Get-PackageSource
if(@($MypS).Where{$_.location -eq $_nugetUrl}.count -eq 0)
{
   Register-PackageSource -Name MyNuGet -Location $_nugetUrl -ProviderName NuGet
}

I got the following error: see below ,Powershell not able to access “NuGet” package

Unable to find package providers (NuGet)

Why are we getting this error, and what is the solution to this error?

The first step is to verify the version of the Transport Layer Security protocols using the following PowerShell cmdlet.

PS C:\WINDOWS\system32> [Net.ServicePointManager]::SecurityProtocol

Once you run the above PowerShell cmdlet, you can see the version of Transport Layer Security protocols available on your system. If the versions are very old and even deprecated, you need to enable the latest version.

Solution

Install-PackageProvider

To fix the, Unable to install NuGet provider error in PowerShell, we need to follow the steps below to fix the Unable to find package provider ‘NuGet’ issue.

1. Open PowerShell as run as Administrator.

2. Run the below command to enable TLS 1.2, or you can also enable TLS 1.3 or even any higher versions.

[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12

or

[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls13

3. Run the below command

Install-PackageProvider -Name NuGet

See the output here. This time, I can successfully install the NuGet package provider without any issue. Check out the screenshot below for your reference.

Unable to find package providers (NuGet) how to fix

This is how I install the NuGet Provider for PowerShell without any issue.

Conclusion

In this article, we learned how to fix the error “Unable to find package providers (NuGet).” Now, you can install NuGet for PowerShell without any issues.

You may like the following Azure tutorials:

Azure Virtual Machine

DOWNLOAD FREE AZURE VIRTUAL MACHINE PDF

Download our free 25+ page Azure Virtual Machine guide and master cloud deployment today!