This is a post in a series of blog articles about troubleshooting typical error situations in PowerShell cmdlets in the cloud. This time it’s about…
You try to install a Powershell Module, for example MSOnline, AzureAD, AzureADPreview, ExchangeOnlineManagement or some other module from the PowerShell Gallery needed for cloud scripting. And then, you get this error message:
Fun fact: The PSGallery deprecated Transport Layer Security (TLS) versions 1.0 and 1.1 as of April 2020. Here is the announcement on the Microsoft DevBlog post. So you might be blocked because your machine’s security protocol setting is still stuck with version 1.0 or 1.1. So now it’s time to set a better TLS level:
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
After this, try the module installation again. If the error is still there, then we should start reading the error message carefully (you always do, don’t you ? 😉 ) and try getting the cmdlet that is proposed here:
If you get an empty list – or you don’t see the PSGallery in the list of PowerShell module repositories, you should first try to register the PSGallery again. Because without the PSGallery as a repository, the cmdlets Install-Module, Update-Module, or Find-Module cannot work. So next step is to try the repository registration:
Register-PSRepository -Default -Verbose
After this, try the module installation again. It should work now.