Question

I have Powershell 3 installed on my box.

I need to test some scripts with Powershell 4 but I want to continue to run some of my scripts that are tested under Powershell 3 and I do not want to break something by installing Powershell 4.

QUESTION:Is it possible to open a Powershell sessions under Powershell version 3 (or even 2 if needed) despite I have installed Powershell 4?

Était-ce utile?

La solution 2

Yes. Starting with V3, you could open a powershell session for a downlevel version using the -Version parameter.

-Version
    Starts the specified version of Windows PowerShell.
    Enter a version number with the parameter, such as "-version 2.0".

So running

Powershell.exe -Version 2 

will start a session that can be used to run/test a V2 script.

Autres conseils

When you have the Windows Management Framework Core 4.0 package installed, you can run PowerShell version 2.0, but not 3.0. Use the -version 2.0 parameter to launch PowerShell v2.

See this TechNet article: http://technet.microsoft.com/en-us/library/hh847899.aspx

Also see the help about_powershell.exe help documentation: http://technet.microsoft.com/en-us/library/jj553275.aspx

To frame the information in user189198's helpful answer a bit differently, with the benefit of hindsight:

  • No, v3 can not run alongside v4, v5, or v5.1, the latest and last version of Windows PowerShell.

    • Only one of these versions can be installed.
  • In v3, v4, v5, and v5.1, the only version you can run alongside is v2.

    • However, doing so requires .NET Framework 2.0 to be installed (v2.0.50727, per the error message you get if it isn't installed), which is no longer a given in recent versions of Windows (which come with Windows PowerShell v5.1), where you may have to install it manually.

By contrast, there are no limitations on what versions of PowerShell (Core) 7+ - the modern, install-on-demand, cross-platform successor to the legacy, ships-with-Windows, Windows-only Windows PowerShell - you can install and run alongside each other.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top