views:

108

answers:

1

PowerShell's help (powershell -?) states:

-Version
    Starts the specified version of Windows PowerShell.

However, when starting PowerShell 2 with powershell -Version 1 all things I tried that are only present in v2 and not v1 still work, such as the -split operator or the Get-Random cmdlet.

So what exactly changes when running PowerShell with the -Version parameter if language features and cmdlets that were introduced later still exist and work? This makes testing scripts for PowerShell v1 a bit harder since I don't always remember what has changed.

+2  A: 

I don't think this switch does anything especially since 1.0 and 2.0 can't be installed side-by-side. This switch was put in from the beginning. My guess is that they anticipated being able to run different versions of PowerShell side-by-side. Perhaps that will happen with some future version that installs side-by-side and then this switch will be actually useful.

Keith Hill
Hm, makes me wonder why they catch versions other than 1 or 2 and output an error message *(»Cannot start Windows PowerShell version 3 because it is not correctly installed.«)* but don't do this for version 1 which would have the same error, actually.
Joey
Another guess - they consider 2.0 backwards compatible with 1.0?
Keith Hill
Probably the same reason why 2.0 installs to the system32\WindowsPowerShell\v1.0 directory.
Richard Berg
I've actually confirmed that PowerShell 1.0 and 2.0 run just fine side by side if you take the GAC'd assemblies out of the equation. So I wouldn't be surprised if someday powershell.exe is just a launcher much like how *.sln files are associated with a Visual Studio stub that opens the correct version.
Josh Einstein