How to Download and Install the Latest Version of PowerShellGet Module

Table of Contents

Upgrade PowerShellGet module

PowerShellGet is a powerful module with commands for discovering, installing, updating and publishing PowerShell artifacts like Modules, DSC Resources, Role Capabilities, and Scripts.

But the old version of PowerShellGet doesn’t have parameter -AllowPrerelease to install preview modules. By default, PowerShell 5.1 included PowerShellGet 1.0.0.1.

PS C:> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      5.1.19041.1682
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.19041.1682
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

PS C:> Import-Module PowerShellGet
PS C:> Get-Module PowerShellGet

ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Script     1.0.0.1    PowerShellGet                       {Find-Command, Find-DscResource...

Install NuGet provider

1️⃣ Before updating PowerShellGet, you should always install the latest NuGet provider. From an elevated PowerShell session, run the following command.

Install-PackageProvider -Name NuGet -Force

2️⃣ Register PSGallery repositories if not setup before.

Set-PSRepository -Name PSGallery -InstallationPolicy Trusted -ErrorAction Stop

3️⃣ If you see an exception like Powershell Gallery is currently unavailable, register PSGallery as default.

Register-PSRepository -Default

Install PowerShellGet

Once the Nuget package provider is installed. We can move forward to install the PowerShellGet module using PowerShell. Run below command in an elevated PowerShell console.

Install-Module -Name PowerShellGet -Force

Anytime, you can use Update-Module to get newer versions.

Update-Module -Name PowerShellGet

Check the installed PowerShellGet version.

PS C:\> Get-InstalledModule PowerShellGet

Version Name          Repository Description
------- ----          ---------- -----------
2.2.5   PowerShellGet PSGallery  PowerShell module with commands for discovering, publishin...

Leave a Comment

Required fields are marked *