Update powershell to the latest revision

I have two different revision of PowerShell in different machines. The local one have the following one:

Major Minor Build Revision
5 1 17763 1007

And the virtual machine has the following one:

Major Minor Build Revision
5 1 17763 771

As you can see that it has the same: Major, Minor, and Build values except the Revision values. I am not sure if it is behind the failure of the command:

Register-PSRepository -Name $RepoKeyName -SourceLocation $RepoKeyValue -PublishLocation $RepoKeyValue -InstallationPolicy Trusted -Verbose 

The above snippet works fine on the local machine but not on the virtual machine and it fails in the virtual machine with the following error:

parameter 'SourceLocation' is an invalid Web Uri. Please ensure that it meets the Web Uri requirements.

And this is why I want to update the PowerShell in the virtual machine to the latest revision value. How to do it?

0

6 Answers

If you have Microsoft's winget app (Windows package manager), you can run the following command to update to the most recent version of PowerShell:

winget install Microsoft.PowerShell 
4
If you're running Windows 11 or have updated App Installer in Windows 10.

Update PowerShell using Windows Package Manager (winget)

winget upgrade Microsoft.PowerShell 

You also can install PowerShell by using below command via winget

winget install Microsoft.PowerShell 

Learn more:

Invoke-Expression "& { $(irm ) } -UseMSI"

Run the following command from command prompt wait till gets downloaded, and it will prompt to installation wizard follow the instructions to install it.

1

You can never update Windows PowerShell installations on demand - except, in the past, if you upgraded to a new major version, but v5.1 is the last version that will ever be released, given that Windows PowerShell is in maintenance-only will see no new development, unlike its successor, the cross-platform PowerShell (Core) 7+ edition.[1]

Revisions of v5.1 are delivered as part of Windows updates.

However, you can selectively update the PowerShellGet module, in which the problem-causing Register-PSRepository command is defined:

While you normally would just run Update-Module PowerShellGet, a different approach is required the first time, when switching from the bundled PowerShellGet module to the latest version from the PowerShell Gallery:

  • Open an elevated session (Run as Administrator).

  • Execute the following (add -Verbose to get detailed information):

     Install-Module PowerShellGet -Force 

The -Force is to enable installation even though a module by that name is already installed; you may still see a prompt about downloading the NuGet package provider.
Note that the old PowerShellGet version will linger in a different location, but the new one will take precedence over it.

After this initial switch to the gallery-installed version, you'll be able to use
Update-Module PowerShellGet for future versions.


You can use the Get-Command cmdlet to discover a given command's module of origin; e.g.:

PS> (Get-Command Register-PSRepository).Module ModuleType Version PreRelease Name ExportedCommands ---------- ------- ---------- ---- ---------------- Script 2.1.4 PowerShellGet {Find-Command, Find-DscResource, Find-Module, Find-RoleCapability…} 

[1] PowerShell (Core) 7+ versions can be updated on demand - however, as of v7.1, PowerShell [Core] doesn't come with Windows and requires manual installation. However, you can now install and update it via the Microsoft Store application.

0

Solution1: Go to this link:

Find Assets and click on Assets word.

Download and install .msi link.


Solution2:

Go to this link for download Windows Package Manager:

Find Assets and click on Assets word.

Download : Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle

Execute the downloaded file and click on update.

Open your command prompt or powershell and execute this command on it:

winget install Microsoft.PowerShell

If you have Mircrosoft.PowerShell execute this command:

winget upgrade Microsoft.PowerShell


For figure out your powershell version: execute host command in your powershell. enter image description here

Forget the noise and the drama:

iex "& { $(irm ) } -UseMSI -Quiet" 

Put that into PowerShell as an admin.

2

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like