Can I run PowerShell in version 3 or 4 mode when installing PowerShell 5?

I currently have Windows Management Framework 5.1 installed. I want to check that my script is working correctly with PowerShell 3 and 4. I know about this PowerShell.exe -Version, but when I try:

PowerShell.exe -Version 3

Or:

PowerShell.exe -Version 4

And then run $PSVersionTable, still showing PowerShell 5.1 as the current version.

If I run:

PowerShell.exe -Version 2

Then it $PSVersionTableshows that the console now has version 2. Why is this?

+4
source share
1 answer

Windows PowerShell provides a special backward compatibility mode -Version 2.0that allows you to run PowerShell version 2, even if you have later versions installed:

PowerShell, , , PowerShell 3 4 PowerShell 5 ( PowerShell.exe -version 3 /). PowerShell ( PowerShell Core, Windows PowerShell).

PowerShell PowerShell ( 2) - PowerShell .

Windows PowerShell 4.0 Windows PowerShell 3.0 Windows PowerShell 2.0. , , , , Windows PowerShell 2.0 Windows PowerShell 4.0 Windows PowerShell 3.0. - Microsoft.NET Framework 4, Windows PowerShell, Windows PowerShell 2.0 Common Language Runtime (CLR) 2.0 Windows PowerShell 3.0 Windows PowerShell 4.0, CLR 4.0. PowerShell 2.0 Engine , script - , Windows PowerShell 4.0, Windows PowerShell 3.0 Microsoft.NET 4. , .

+4

Source: https://habr.com/ru/post/1678875/


All Articles