Why is Powershell 2.0 installed in the same location as Powershell 1.0?

I just think that, at the very begining, Microsoft team plan to deploy PowerShell versions side by side, just as it's done for the Framework .NET versions. But with the time they decided to support only one PowerShell at the time.

There something even more strange when you use the -version parameter of the command line to choose version 1.0 the var $PSVersionTable is present with PSVersion valued to 2.0. $PSVersionTable is not present in PowerShell 1.0

C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC>powershell -version 1.0
Windows PowerShell
Copyright (C) 2009 Microsoft Corporation. Tous droits réservés.

PS C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC> cd \
PS C:\> $PSVersionTable

Name                           Value
----                           -----
CLRVersion                     2.0.50727.4952
BuildVersion                   6.1.7600.16385
PSVersion                      2.0
WSManStackVersion              2.0
PSCompatibleVersions           {1.0, 2.0}
SerializationVersion           1.1.0.1
PSRemotingProtocolVersion      2.1

If you have a look on var $host which exists on both versions

PowerShell V2.0 (vith version 1.0 or 2.0)

PS > $host
Name             : ConsoleHost
Version          : 2.0
InstanceId       : b6ae2582-c1f4-422a-b057-16458b387f7d
UI               : System.Management.Automation.Internal.Host.InternalHostUserInterface
CurrentCulture   : fr-FR
CurrentUICulture : fr-FR
PrivateData      : Microsoft.PowerShell.ConsoleHost+ConsoleColorProxy
IsRunspacePushed : False
Runspace         : System.Management.Automation.Runspaces.LocalRunspace

PowerShell V1.0

PS > $Host
Name             : ConsoleHost
Version          : 1.0.0.0
InstanceId       : b55940f2-b3b2-4f99-b895-98aac4752369
UI               : System.Management.Automation.Internal.Host.InternalHostUserInterface
CurrentCulture   : fr-FR
CurrentUICulture : fr-FR
PrivateData      : Microsoft.PowerShell.ConsoleHost+ConsoleColorProxy

My opinion is that PowerShell V2.0 is able to run almost all PowerShell V1.0 scripts. Microsoft add some vars and you can get troubles if you have these vars present in you scripts but it's peanuts.

JP


It's actually an interesting story in side-effects.

Visual Studio has a fixed list of assemblies in their "Add Reference" dialog.
Anything else has to be browsed for. Developers tended to browse for this location in the Windows directory, where System.Management.Automation.dll (the assembly that runs most of PowerShell lives) This made an absolute reference to this location. Since there wasn't going to be a side-by-side install option with PowerShell (as there is with the .NET framework), the best choice available was to allow people to keep referencing the same assembly, both by path and by StrongName, as they did before.

If this story hadn't have stayed this way, all applications written on top of PowerShell V1 would have to be re-released for V2.


I think because PowerShell 2.0 is extremely compatible with 1.0, there was no need to have two different versions on the same machine. So they put 2.0 over top of 1.0 on XP and Vista systems and most likely decided to keep the same directory for Windows 7. This is also the same reason the extension is still .ps1 (and .psm1, .psd1).

You could ask the same for Windows 7 x64. Why are the 64-bit system dlls in a dir called System32 and why do those same 64-bit dlls' names end with "32" e.g. user32.dll, kernel32.dll, etc. :-)