Home ยป How to Install and Update PowerShellGet Module

How to Install and Update PowerShellGet Module

The PowerShellGet is a module that provides commands for finding, installing, updating, and publishing PowerShell tools like Modules, Scripts, and DSC resources.

PowerShell 5.1 includes PowerShellGet version 1.0.0.1 by default. This version has limited functionality and lacks compatibility with the latest features of the PowerShell Gallery.

In the article, we will discuss how to:

  • Install the latest PowerShellGet version.
  • Install a specific PowerShellGet version.
  • Update the default PowerShellGet version.

System Requirements

To install PowerShellGet, ensure your system meets the following requirements:

  • .NET Framework 4.5 or higher: This is necessary to run PowerShellGet. Install .NET Framework.
  • TLS Version 1.2: PowerShell Gallery no longer supports TLS 1.0 and 1.1, so you must enable TLS 1.2. To enable TLS 1.2 in your PowerShell session, run this command:
[Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12

Steps to Install PowerShellGet

  1. Launch PowerShell with Administrator privileges.
  2. Install the NuGet Provider: PowerShellGet requires NuGet to manage packages. Install it using:
Install-PackageProvider -Name NuGet -Force

3. Install PowerShellGet Module: Install the latest PowerShellGet version by running:

Install-Module PowerShellGet -AllowClobber -Force

4. Restart PowerShell: Close the current PowerShell window and open a new session. This refreshes the module list and loads the latest version.

Install a Specific PowerShellGet Version

To install a specific version of PowerShellGet, like 2.2.5, use the following command.

Install-Module -Name PowerShellGet -RequiredVersion 2.2.5 -Force

In this script, the -Name PowerShellGet specifies the module name. -RequiredVersion 2.2.5 installs version 2.2.5. The -Force bypasses prompt for installation.

Update PowerShellGet Module

To upgrade PowerShellGet to the latest available version, run the following command:

Update-Module -Name PowerShellGet

After updating, restart PowerShell to load the new version.

Conclusion

To install or update PowerShellGet:

  • Use Update-Module to upgrade to the latest version.
  • Use Install-Module to install a new version.

You can find more topics about Active Directory tools and PowerShell basics on the ActiveDirectoryTools home page.