Update PowerShellGet and PackageManagement
Since I am just setting up a new work machine, I wanted to share some information how you can update PowerShellGet and PackageManagement to the latest version. This will give you the usual bug fixes and performance enhancements. Since you don’t get the latest version in Windows PowerShell nor PowerShell Core, you will need to update it manually.
PowerShellGet is a PowerShell module with commands for discovering, installing, updating and publishing the PowerShell artifacts like Modules, DSC Resources, Role Capabilities and Scripts. For example you use PowerShellGet to install the Azure PowerShell module, or other modules.
PowerShellGet module is also integrated with the PackageManagement module as a provider, users can also use the PowerShell PackageManagement cmdlets for discovering, installing and updating the PowerShell artifacts like Modules and Scripts.
How to update PowerShellGet and PackageManagement
Updating to the latest version of PowerShellGet and the PackageManagement module is simple. Since both modules are part of the PowerShell Gallery, you can update them using a couple of simple commands.
You can find both modules in the PowerShell Gallery:
First lets check which versions of the modules you have available. If you use Update-Module, it will automatically load PowerShellGet and PackageManagement and list them as loaded PowerShell modules. Of course you can also use Get-Module -ListAvailable.
Get-Module -ListAvailable PackageManagement, PowerShellGet
As you can see, In my default installation, I got PowerShellGet version 1.6.7 and PackageManagement 22.214.171.124. If you have a look at PSGallery, you will see that these are pretty old versions and that there are newer available.
To get the latest version from PowerShell Gallery, you should first install the latest Nuget provider. You will need to run PowerShell as an Administrator for all the following commands.
Install-PackageProvider Nuget –Force Exit
If you run PowerShell 5.0 or newer, you can install the latest PowerShellGet using the following command. PowerShell 5.0 is included in Windows 10, Windows Server 2016, Windows Server 2019, any system with WMF 5.0 and 5.1 or a system running PowerShell 6.
Install-Module –Name PowerShellGet –Force Exit
Two quick tips, first of, you will need to set the execution policy to RemoteSigned to allow the new module to run. Secondly in some cases you will need to use the -AllowClobber parameter to install the updated version of the module.
Set-ExecutionPolicy RemoteSigned Install-Module –Name PowerShellGet –Force -AllowClobber
You can then use Update-Module to get newer versions:
Update-Module -Name PowerShellGet Exit
After that you will see the latest versions of PowerShellGet and PackageMangement available
If you run older versions of PowerShell you can check out the full documention on the PowerShell Docs. I hope this blog post helps you to update PowerShellGet and benefit from the latest versions. If you have any questions, please let me know in the comments.