Reputation: 1013
I am using the .NET PowerShell host. I have version 5 and 7 installed of PowerShell. When running:
$PSVersionTable.PSVersion
Major Minor Build Revision
5 1 18362 1110
How do I make it run version 7 of PowerShell?
Upvotes: 0
Views: 1292
Reputation: 1979
From Microsoft's documentation, you should be able to load a previous version of PowerShell.
Separate installation path and executable name
PowerShell 7 installs to a new directory, enabling side-by-side execution with Windows PowerShell 5.1.
Install locations by version:
Windows PowerShell 5.1: $env:WINDIR\System32\WindowsPowerShell\v1.0
PowerShell Core 6.x: $env:ProgramFiles\PowerShell\6
PowerShell 7: $env:ProgramFiles\PowerShell\7
The new location is added to your PATH
allowing you to run both Windows PowerShell 5.1 and PowerShell 7. If you're migrating from PowerShell Core 6.x to PowerShell 7, PowerShell 6 is removed and the PATH
replaced.
In Windows PowerShell, the PowerShell executable is named powershell.exe
. In version 6 and above, the executable is named pwsh.exe
. The new name makes it easy to support side-by-side execution of both versions.
Have a read of the webpage, using the link provided.
Upvotes: 3
Reputation: 3193
From a console just do
where powershell.exe
-and-
where pwsh.exe
you should obtain:
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
-and-
C:\APL\Microsoft\PowerShell64\pwsh.exe
then you can call the .exe(s) direcly...
to bypass any issues with .cmd(s)/.bat(s)/.lnk(s)/alias/hijackers/etc. etc.
Upvotes: 1
Reputation: 17154
Powershell (Core) 7 is a different executable: pwsh.exe
powershell => Windows PowerShell (latest: v5.1)
pwsh => PowerShell Core (latest: v7)
Upvotes: 1