0

My powershell version is:

Name                           Value
----                           -----
PSVersion                      5.1.19041.1682
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.19041.1682
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

I have the following command that will update to the latest version:
iex "& { $(irm https://aka.ms/install-powershell.ps1) } -UseMSI"

Can I use the above command to update my Powershel or is there another way to do this?

If I update the powershel, will the scripts I already have work normally?

4
  • If the script will work with PowerShell Core is entirely dependent on the script. The command will download PowerShell Core.
    – Ramhound
    Commented May 20, 2022 at 16:08
  • @Ramhound so this command doesn't upgrade to the latest powershell is that it?... what do you suggest me? It's my first time doing this!
    – Clamarc
    Commented May 20, 2022 at 16:20
  • I never said it wouldn’t download the current version of PowerShell Core. Where did you get that impression or is it because you don’t realize the current version of PowerShell is current version of PowerShell Core?
    – Ramhound
    Commented May 20, 2022 at 18:32
  • there are TWO types of powershell --- [1] Windows powershell [powershell.exe version 5.1] ///// [2] what once was named powershell core but is now named "powershell" [pwsh.exe version 7+] ///// the command you posted will install/upgrade the 2nd of those ... pwsh.exe. ///// they can exist side-by-side & you cannot safely remove the windows version since it is deeply embedded in windows ... but it will not be upgraded. the cross-platform ps7+ will be upgraded.
    – Lee_Dailey
    Commented May 20, 2022 at 22:40

2 Answers 2

1

PowerShell 5.x ist part of the OS installation.

iex "& { $(irm https://aka.ms/install-powershell.ps1) } -UseMSI" will install the current PowerShell Core 7.x as a seperate product, which is not fully compatible.

3
  • OK, so I'll stick with the official version anyway, thanks!
    – Clamarc
    Commented May 20, 2022 at 17:30
  • @Clamarc - PowerShell 5.x isn’t updated. If you want the current version of PowerShell you’ll want to use the command you asked about
    – Ramhound
    Commented May 20, 2022 at 18:08
  • @Ramhound...I decided not to use the command because M. Behrens replied that the command would install a separate product which might be incompatible?!...so the command will update my powershell without being a separate product, that's it ???.
    – Clamarc
    Commented May 21, 2022 at 15:01
0

As the other comments and answers say, you can't replace PS 5.1 with PS Core, but you can have them both installed. PS Core is the one that MS wants you to use and the current version that gets updated frequently.

If you want to install/update your PS Core Version, another way is to use winget

On Windows 11 and some Versions of Windows 10 it's already installed by default otherwise you can download it here

to search for packages:

winget search powershell

to install packages:

winget install PowerShell

and the beauty of it is, when there is an upgrade available you can simply do:

winget upgrade PowerShell

Here's an example output from my upgrade that i just did:

PS C:\Users> winget upgrade powershell
Found PowerShell [Microsoft.PowerShell] version 7.2.4.0
This application is licensed to you by its owner.
Microsoft is not responsible for and does not license third-party packages.
Downloading https://github.com/PowerShell/PowerShell/releases/download/v7.2.4/PowerShell-7.2.4-win-x64.msi
  ██████████████████████████████ 101 MB / 101 MB
The installer hash was successfully verified
Package installation is started...

PS C:\Users>
4
  • OK... but after the upgrade, when I run a script they will be: 1 - run from the new powershell prompt? 2 - Will existing scripts run without compatibility issues? 3 - Is Powershell ISE also updated?... I have many scripts and I would like to know what impacts may occur with the upgrade, ok?
    – Clamarc
    Commented May 23, 2022 at 9:51
  • @Clamarc 1) they will run in the old one if you start them with powershell.exe and in the new one when you start via pwsh.exe. 2) They probably will, except you use stuff that is not available in pwsh you will need to test them. 3) No PowerShell ISE is not updated, because as PowerShell 5.1 it's also not updated anymore. it's recommended that you use Visual Studio Code with the PowerShell extension to create your scripts
    – SimonS
    Commented May 23, 2022 at 12:13
  • OK, thanks for the informations.
    – Clamarc
    Commented May 23, 2022 at 17:37
  • Which is better to install VS Code, User or System?
    – Clamarc
    Commented May 23, 2022 at 17:55

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .