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 18.104.22.168. 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.Tags: Microsoft, Module, Nuget, PackageManagement, PowerShell, PowerShell 6, PowerShell Core, PowerShellGet, update, Update PowerShellGet, Windows, Windows Powershell, Windows Server Last modified: February 19, 2019
Hi, I’ve just installed PS6 and I’d like to use as an update from the default version 5.1 on win10x64. How do I use 6 as default overwritting version 5? Because today I have 2 versions running and I really don’t need it. Thank you.
Today PSCore 6 and Windows PowerShell 5.1 are side by side installations. You are not able to remove Windows PowerShell 5.1 :)
Hello Sir,When I wrote ‘powershell’ on win10x64 CMD , PowerShell 5.1 was opened as usual.Is there any chance of opening ‘PSCore 6’ from win10x64 CMD?Thank you.
You can type: pwsh to open PowerShell Core 6 from cmd.
I get messsage
WARNUNG: The version ‘1.4.5’ of module ‘PackageManagement’ is currently in use. Retry the operation after closing the
How I close that?
Is there a way to open pwsh 6 as default?
I mean, currently when I use the cmd shortcut (winkey+x; a) it opens pws 5.1.
There’s no problem in having both, I just wanted to use pwsh 6 as default.
I got the same error. This fixed it for me.
Get-Module | Remove-Module
Very helpful, updated the Teams Module preview 1.1.10 today. Had to run Update-Module with Install-Module.