Transport Layer Security known as TLS is a very important part while using URI commands such as Invoke−WebRequest or Invoke−Restmethod commands and package commands such as Find−Package or Install−Package because they interact on the internet and PowerShell needs TLS1.2 version for that.
We may get the below errors when we use the lower TLS version.
WARNING: Unable to download the list of available providers. Check your internet connection. WARNING: Unable to resolve package source 'https://www.powershellgallery.com/api/v2'. Find-Package : No match was found for the specified search criteria and package name
To resolve the above error, we need to change the TLS version. To check the existing TLS version, we can use the below command,
PS C:\> [Net.ServicePointManager]::SecurityProtocol Ssl3, Tls
To change the TLS version to 1.2 below command can be used.
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12