PowerShell 5.1 as shipped with Windows 10 and 11 includes versions 1.0.0.1
of PackageManagement
and PowerShellGet
this old version cannot install most modern modules, nor can it self update properly.
In most cases fixing this runs into numerous issues with conflicting versions or files in use. This script is an adaptation of a script by Chris Taylor which takes a different approach to downloading the modules, has a bit more error checking and further installs the new PSResourceGet
module which is the replacement for PowerShellGet
.
The Script
loading...
Usage
.\Initialise-PowerShellGet.ps1
Nice and simple on this one, just run the script and it will do the rest. It does expect a close-to-vanilla install of Windows 10 or 11, so if you've been messing around with the default modules before running this script, it may not work as expected.