1

Different commands tell me I have different versions of PowerShell. (1) Why? (2) Do I need to care?

Following some of the advice here and on other sites I used WinGet to install a later version of PowerShell. Or so I thought.

Every time I start PowerShell I get a header saying 'Try the cross platform version at ....' I thought I had done that before but tried again. Several methods offered so I tried winget for 7.1 version.

Before starting $PSVersionTable.PSVersion said I had 5.1. Winget ran for a while and then said I had to uninstall previous version. Deep breath and then I used winget uninstall microsoft.powershell. Appeared to run smoothly. Then reran install.

Also appeared to run smoothly and reported success. I closed PowerShell and restarted. Still get the 'Try the crossplatform ...' message. $PSVersionTable.PSVersion still reports 5.1. As does Get-Host. But pwsh --version says 7.3.6

What do I really have? And, as with so many upgrades, does it really make any difference?

pwright2
  • 11
  • 2

1 Answers1

2

PowerShell 5.1 is also known as Windows PowerShell which is the older Windows-only version and is launched via powershell.exe.

The modern open-source cross-platform version is PowerShell 7.x (also called PowerShell Core 7.x as it's built on top of dotnet core) which is launched via pwsh.exe and can exist side-by-side with Windows PowerShell on Windows-based computers.

You'll get reports of either version depending on how you access it - e.g. launching powershell.exe or pwsh.exe on the command line.

Both versions are also integrated into various other software products so you'll get information about the underlying version if you query it - e.g. the older PowerShell ISE embeds Windows PowerShell, whereas the Visual Studio Code PowerShell console uses 7.x, etc.

The two products are mostly compatible, but there are a fair number of breaking changes. If you want a more in-depth discussion of the specifics you can take a look at:

mclayton
  • 8,025
  • 2
  • 21
  • 26
  • Thank you. Very helpful. I have a related (I think) but different issue so I will start another question. Title "Powershell scripts won't run since update to 7." – pwright2 Jul 26 '23 at 00:33