Introduction
When trying to install the Power Shell module using install-module, I have encountered the below issue

In the above scenario, I am trying to install module ‘PSLogging’, (this is used to write the logs to the local and network folders by using the readily built-in functions) and it has thrown me the error. It gives the below message,
PackageManagement\Install-Package: No match was found for the specified search criteria and module name ‘PS Logging. Try get-PSRepository to see all the registered module repositories.
When trying to run the command Get-PSRepository, it is giving the message ‘Unable to find module repositories’.

Background
Before going into the error details, let's try to understand what Install-Module does. The cmdlet Install-Module gets one or more modules based on the specified criteria from Microsoft PowerShell online repository https://www.powershellgallery.com/. All the final versions of the modules are carefully inspected and are published in Microsoft PowerShell Online repositories by MSFT. These modules are developed by Internal MSFT team and from the third parties and individual contributors.
In some organizational environments, the network traffic is restricted and these are tunneled through secure proxies. It is required to authenticate to a proxy server before running the install-module. The other reasons could be latest TLS secure channel might not have been enabled. You can find more about the TLS in the references section.
Method 1: Enabling latest TLS secure channel
To enable the TLS1.2 (which is the latest version while writing this article) in PS scripts, you need to add the below line at the very start
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
Method 2: Authenticating to Web Proxy
In some cases, you might have to exclusively authenticate to proxy server using your network credentials. Using PowerShell you can run the below line of commands to authenticate to proxy server.
Step 1: Get the default proxy
Get the default proxy that is defined at your system configuration level by running the below command.
[System.Net.WebRequest]::DefaultWebProxy = [System.Net.WebRequest]::GetSystemWebProxy()
In some cases, it may be needed to authenticate to proxy server by defining the URL. In such cases you can use the below syntax.
[System.Net.WebRequest]::DefaultWebProxy = New-Object System.Net.WebProxy("http://WEBPROXYURL:PORT",$true)



Join the conversation! Your thoughts help the community grow.