To bring Get-PowerShell and Update-PowerShell cmdlet that will be capable of downloading and upgrading existing version of PowerShell to the newest. For example: Upgrade from PowerShell 7 to PowerShell 7.1
Cmdlets itself will check for the updates available online (or local repository) and give back an output like:
The Newest PowerShell update is available:
NewPSVersion 7.0.1
PSVersion 7.0.0
And some parameters -silent
and -whatif
or -filetype
will do a trick.
In effect you have this already. The PowerShell team have created a simple script you can download like this (doing it the long way!)
# Download (once) this script
URI = "https://aka.ms/install-powershell.ps1"
Invoke-RestMethod -Uri $URI | Out-File -FilePath C:\Foo\Install-PowerShell.ps1
# Then run it
$EXTHT = @{
UseMSI = $true
Quiet = $true
AddExplorerContextMenu = $true
EnablePSRemoting = $true
}
C:\Foo\Install-PowerShell.ps1 @EXTHT
Just run the script.
You could even add this to your PowerShell 7 $Profile:
C:\Foo\Install-PowerShell.ps1 @EXTHT &
That kicks off the install script as a batch job. The script takes only 30-40 seconds, so as long as you are in PowerShell 7, any updates get loaded in the background. Next time you start PowerShell it's upgraded.
IMHO what would be nice is a simple, and built-in way to test for the update. PowerShell currently prints out a warning message at startup that says there is a new version. If there were a command to, in effect, recreate the test. SO something like Test-PSVersion that did the same test and returns true if there IS no newer version and false if there IS a newer version. You could get fancy and have the command determine if the build is preview or daily and do similar (test whether there is a newer daily build or whether there is a newer preview build
It's still a crutch but a good solution!
IMHO what would be nice is a simple, and built-in way to test for the update. PowerShell currently prints out a warning message at startup that says there is a new version. If there were a command to, in effect, recreate the test. SO something like Test-PSVersion that did the same test and returns true if there IS no newer version and false if there IS a newer version. You could get fancy and have the command determine if the build is preview or daily and do similar (test whether there is a newer daily build or whether there is a newer preview build
This is make sense. I think having at least something for "to do with PoSh updates" will become useful
I think the current warning that Powershell shows at startup when a new version is available is somewhat misleading. It gives you two options: go to this URL, or .... do a command? What command?
IMO there's a gap in the user story here. The warning would be more helpful if it looked like the following (loose paraphrase):
A new version of Powershell, v7.x, has been released.
Would you like update now? [Y/N/D]
[Y]es, update now (you will be informed upon completion)
[N]o, not now, but remind me next time I open Powershell
[D]on't bother me until the next version comes out.
out of curiosity, how did you get that prompt? When I run PowerShell 7.0.0, I just get a warning, like this:
out of curiosity, how did you get that prompt? When I run PowerShell 7.0.0, I just get a warning, like this:
Thatās the prompt I was paraphrasing. Upgrade now OR go to this site?
The implication here is that thereās some way to upgrade without going to the site; at least thatās what it looks like to me. If thereās not some way to āupgrade nowā without going to the site, then the prompt should say, āUpgrade now by going to this siteā
Ahh,I see.
Well, when i see that message, I just run the Install-Powershell.ps1 file to install the upgrade.
Update
is an approved verb. It would be very nice to have a built-in Update-PowerShell
command. It should support -WhatIf
. It should be smart about telling folks what pwsh processes are running on Windows that would necessitate a reboot after install. It should allow the user the opportunity to close those processes and then proceed. I would expect that the script suggests exiting the current shell once the installer has started. It could also take parameters that the installer could use (like enable remoting, add to path, etc). It could also take a -Silent
parameter to do a silent install - in which case perhaps the session should end (on Windows at least) to prevent a reboot being required.
Update
is an approved verb. It would be very nice to have a built-inUpdate-PowerShell
command.
I forgot about Update
verb. I have changed the title according to the information you provided.
Update-PowerShell gets my vote. If so - then the command could update the fully installed version, but also be able to update build of the day and preview. The proposed cmdlet should be able to update ANY install of PowerShell (release, preview, and daily), irrespective of how you install them (msi vs zip).
The issue's description was updated to the current conclusion.
I think an Update-PowerShell
cmdlet could be made that detects how that running instance was installed and use that same method to update: apt, yum, winget, brew, MS store, etc... in the case it cannot tell, it would just provide a link to the install PowerShell doc. One potential problem on Windows is due to open file handles, if this cmdlet starts the MSI installer, you would have to close pwsh to update pwsh, but I think because the MSI process is a child process of pwsh, if you close pwsh, it will kill the MSI installer as well.
Yes please!
And if you use the MSI, you CAN kill the PowerShell console - and the MSI will continue to work just fine. I use this method all the time to update major versions. I just run Install-PowerShell.ps1 (from Gitub), specify -USEMSI. Then once the MSI has started, I just kill the PowerShell task and click through the installation.
Most helpful comment
I think the current warning that Powershell shows at startup when a new version is available is somewhat misleading. It gives you two options: go to this URL, or .... do a command? What command?
IMO there's a gap in the user story here. The warning would be more helpful if it looked like the following (loose paraphrase):