Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Windows 7 为什么Powershell 2.0与Powershell 1.0安装在同一位置?_Windows 7_Powershell_Powershell 2.0 - Fatal编程技术网

Windows 7 为什么Powershell 2.0与Powershell 1.0安装在同一位置?

Windows 7 为什么Powershell 2.0与Powershell 1.0安装在同一位置?,windows-7,powershell,powershell-2.0,Windows 7,Powershell,Powershell 2.0,有人知道为什么Powershell 2.0安装在C:\Windows\System32\WindowsPowerShell\v1.0的Windows 7设备上吗?我认为,由于Powershell 2.0与1.0非常兼容,因此不需要在同一台机器上安装两个不同的版本。因此,在XP和Vista系统上,他们将2.0置于1.0之上,并且很可能决定在Windows7上保留相同的目录。这也是扩展名仍然是.ps1(和.psm1、.psd1)的原因 对于Windows 7 x64,您也可以提出同样的要求。为什么6

有人知道为什么Powershell 2.0安装在C:\Windows\System32\WindowsPowerShell\v1.0的Windows 7设备上吗?

我认为,由于Powershell 2.0与1.0非常兼容,因此不需要在同一台机器上安装两个不同的版本。因此,在XP和Vista系统上,他们将2.0置于1.0之上,并且很可能决定在Windows7上保留相同的目录。这也是扩展名仍然是.ps1(和.psm1、.psd1)的原因


对于Windows 7 x64,您也可以提出同样的要求。为什么64位系统dll在一个名为System32的目录中,为什么相同的64位dll的名称以“32”结尾(例如user32.dll、kernel32.dll等):-)

我只是认为,在一开始,微软团队计划并排部署PowerShell版本,就像在Framework.NET版本中一样。但随着时间的推移,他们决定只支持一个PowerShell

当您使用命令行的-version参数选择版本1.0时,会出现更奇怪的情况var
$PSVersionTable
,PSVersion值为2.0$PowerShell 1.0中不存在PSVersionTable

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
如果您查看两个版本中都存在的var
$host

PowerShell V2.0(第1.0版或第2.0版)

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
我的意见是,PowerShell V2.0能够运行几乎所有PowerShell V1.0脚本。Microsoft添加了一些变量,如果脚本中存在这些变量,您可能会遇到麻烦,但这只是小菜一碟


这实际上是一个关于副作用的有趣故事

Visual Studio在其“添加引用”对话框中有一个固定的程序集列表。
还有什么需要浏览的吗。 开发人员倾向于在Windows目录中浏览此位置,System.Management.Automation.dll(运行大多数PowerShell的程序集)位于该目录中 这绝对是指这个位置。 由于PowerShell没有并行安装选项(就像.NET framework一样),因此最好的选择是允许用户像以前一样,通过路径和strong名称不断引用同一程序集


如果这个故事不是这样的话,所有写在PowerShell V1上的应用程序都必须重新发布到V2上。

这不是GAC的目的吗?哦,顺便说一句,包括你在每个答案上的签名都是浪费空间:)Windows 8(预览版)中的PowerShell v3也在同一个地方…与“极端兼容性”无关,但是向后兼容。在Windows 8中,它仍然位于C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe中,$PSVersionTable显示了PS3.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