Windows Server

PowerShell: How to update PowerShellGet and Package Management

PowerShell

PowerShellGet is an open-source project, and both the PowerShellGet and PackageManagement modules are available in the PowerShell Gallery. PowerShellGet is now a repo under github.com/PowerShell. The PackageManagement module is already open-sourced as it is part of the OneGet project.  Check out the new PowerShellGet repo at github.com/PowerShell/PowerShellGet.

PowerShellGet is a PowerShell module with commands for discovering, installing, updating, and publishing the PowerShell artifacts like Modules, DSC Resources, Role Capabilities, and Scripts and can be used to install the Azure PowerShell module or other modules.

Update PowerShellGet and Package Management

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. On how to install PowerShell version 7, see https://techdirectarchive.com/2020/05/22/how-to-install-and-update-powershell-version-7-on-windows-and-linux/

Before updating the PowerShellGet or PackageManagement, let us first check the versions of the modules we have available. If you use Update-Module, it will automatically load PowerShellGet and PackageManagement and list them as loaded PowerShell modules.
Note: You can also use the Get-Module -ListAvailable.

update

As you can see above, we have version 1.0.0.1 PowerShellGet and version 1.0.0.1 Package management running.

In order to update PowerShellGet or PackageManagement, you should always install the latest NuGet provider. To do that, run the following in an elevated PowerShell prompt.

Install-PackageProvider Nuget –force –verbose
PowerShellGet

Note: If you have PowerShell 5.0 or above running. you can install both PowerShellGet and PackageManagement together. To do this on Windows 10, Windows Server 2016, or any system with WMF 5.0 or 5.1 installed, run the following commands from an elevated PowerShell prompt:

Install-Module –Name PowerShellGet –Force –Verbose

Next, 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.

Package Management

To get the latest version, the the following command below for this.

Update-Module
Get-Module

After that you will see the latest versions of PowerShellGet and Package Management available.

To permit new modules to run, you will have to set the execution policy to RemoteSigned to allow this. For more on information on execution policy, see
https://techdirectarchive.com/2020/02/04/how-to-set-execution-policy/
https://techdirectarchive.com/2020/02/04/how-to-set-the-powershell-execution-policy-via-the-registry-settings/

Set-ExecutionPolicy RemoteSigned

For how to install PowerShell on Windows and Linux, see https://techdirectarchive.com/2020/05/22/how-to-install-and-update-powershell-version-7-on-windows-and-linux/

I hope this blog post was helpful. If you have any questions, please let me know in the comment section.

Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x