Fix Install-Module not found in PowerShellGet

About

The cmdlet Install-Module can sometimes (especially after a major OS upgrade) break with this vague message:

0c941491-aad1-4610-b705-630f4e8dc1cb-image.png

This cmdlet is provided by the module PowerShellGet which is redistributed with the official PowerShell installation. If you're experiencing this issue, try the following.

The fix

Navigate to the file system path C:\Program Files\WindowsPowerShell\Modules\PowerShellGet where you may see the following directories:

dd59639d-aa16-4bc3-a00c-4e1a06b5d8f6-image.png

If you see one or more folders named differently than 1.0.0.1, delete them. Re-open PowerShell and the installation again. It should now display the expected consent message:

9b8e17d1-509d-4ebd-b923-e07eba5de139-image.png

After confirmation the download and installation will work again.

a70f32f9-fd0d-4933-8557-5f6e2122ae58-image.png

63787ef7-9fff-477f-830a-8681f204b46f-image.png

That's it 😊