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

前端 未结 3 432
Happy的楠姐
Happy的楠姐 2020-12-19 01:27

Does anyone know why Powershell 2.0 is installed in C:\\Windows\\System32\\WindowsPowerShell\\v1.0 on a Windows 7 box?

3条回答
  •  执笔经年
    2020-12-19 02:21

    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

提交回复
热议问题