Repairing Install-Module (PowerShellGet)

by Feb 22, 2021

With Install-Module, you can easily download and install additional PowerShell modules from the PowerShell Gallery (www.powershellgallery.com). However, on Windows systems this command may be broken. Many Windows systems still ship with the outdated version 1.x, and the PowerShell Gallery has switched to the internet protocol TLS 1.2 which isn’t automatically supported by older Windows versions.

To solve problems with Install-Module, you should make sure that PowerShell can use TLS 1.2 to access the PowerShell Gallery:

[System.Net.ServicePointManager]::SecurityProtocol =
[System.Net.ServicePointManager]::SecurityProtocol -bor
[System.Net.SecurityProtocolType]::Tls12

Next, you should manually reinstall the current versions of the PowerShellGet and Packagemanagement modules like this (no Administrator privileges required):

Install-Module -Name PowerShellGet -Scope CurrentUser -Force -AllowClobber
Install-Module -Name Packagemanagement -Scope CurrentUser -Force -AllowClobber

That should fix problems for most users.

If you cannot use Install-Module at all, you could manually copy the module folders for PowerShellGet and Packagemanagement from an updated Windows version to another one. Run this line to find out where the latest version of PowerShellGet can be found:

Get-Module -Name powershellget -ListAvailable | Sort-Object -Property Version -Descending | Select-Object -First 1

The latest version is 2.2.5, and you shouldn’t use a version below 2.x. If your PowerShell reports both version 1.x and 2.x present on your system then all is fine. PowerShell always automatically picks the latest version.


Twitter This Tip! ReTweet this Tip!