安装Windows PowerShell 2.0引擎

本主题将解释如何安装Windows PowerShell 2.0引擎。

Windows PowerShell 3.0 设计上与 Windows PowerShell 2.0 兼容。 为 Windows PowerShell 2.0 编写的指令符、提供者、snap-in、模块和脚本在 Windows PowerShell 3.0 和 Windows PowerShell 4.0 中运行不变。 然而,由于 Microsoft .NET Framework 4 运行时激活策略的变化,为 Windows PowerShell 2.0 编写并用 Common Language Runtime (CLR) 2.0 编译的 Windows PowerShell 主机程序,在后续版本的 Windows PowerShell 中无法运行,而 Windows PowerShell 编译时则是用 CLR 4.0 编译的。

为了保持与受这些变更影响的命令和托管程序的向后兼容性,Windows PowerShell 2.0、Windows PowerShell 3.0 和 Windows PowerShell 4.0 引擎设计为并行运行。 此外,Windows PowerShell 2.0 引擎也包含在 Windows Server 2012 R2、Windows 8.1、Windows 8、Windows Server 2012 和 Windows Management Framework 3.0 中。 Windows PowerShell 2.0 引擎仅在现有脚本或主机程序因与 Windows PowerShell 3.0、Windows PowerShell 4.0 或 Microsoft .NET Framework 4 不兼容而无法运行时使用。 此类案件预计较为罕见。

Windows PowerShell 2.0 引擎是 Windows Server 2012 R2、Windows 8.1、Windows 8 和 Windows Server 2012 的可选功能。 在早期版本的 Windows 上,当你安装 Windows 管理框架 3.0 时,Windows PowerShell 3.0 安装会完全取代 Windows PowerShell 2.0 安装。 不过,Windows PowerShell 2.0 引擎仍被保留。

有关启动 Windows PowerShell 2.0 引擎的信息,请参见 启动 Windows PowerShell 2.0 引擎

在Windows 8.1和Windows 8上

在 Windows 8.1 和 Windows 8 中,Windows PowerShell 2.0 Engine 功能默认开启。 不过,要使用它,你需要开启Microsoft .NET Framework 3.5的选项,这是它所要求的。 本节还解释了如何开启和关闭 Windows PowerShell 2.0 Engine 功能。

开启 .NET Framework 3.5

  1. 开始 画面输入 “Windows 功能”。

  2. 应用 栏,点击 设置,然后点击 “开启或关闭Windows功能”。

  3. Windows功能 框中,点击 .NET Framework 3.5(包括.NET 2.0和3.0 )选择。

    当你选择 .NET Framework 3.5(包括 .NET 2.0 和 .3.0)时,选项框会填充,表示只选中了部分功能。 不过,这对于 Windows PowerShell 2.0 引擎来说已经足够了。

开启或关闭Windows PowerShell 2.0引擎

  1. 开始 画面输入 “Windows 功能”。
  2. 应用 栏,点击 设置,然后点击 “开启或关闭Windows功能”。
  3. Windows 功能 框中,展开 Windows PowerShell 2.0 节点,点击 Windows PowerShell 2.0 引擎 框以选择或清除该节点。

在 Windows Server 2012 R2 和 Windows Server 2012 上

请使用以下步骤添加 Windows PowerShell 2.0 引擎和 Microsoft .NET Framework 3.5 功能。 Windows PowerShell 2.0 引擎至少需要 Microsoft .NET Framework 2.0.50727。 这一需求由 Microsoft .NET Framework 3.5 满足。

添加.NET Framework 3.5功能

  1. 服务器管理器中,从 管理 菜单中选择 添加角色和功能

    或者在 服务器管理器中,点击 “所有服务器”,右键点击服务器名称,然后选择 “添加角色和功能”。

  2. 安装类型 页面,选择 基于角色或基于功能的安装

  3. 功能页面,展开 .NET 3.5 框架功能节点,选择 .NET Framework 3.5(包括 .NET 2.0 和 3.0)。

    该节点下的其他选项在 Windows PowerShell 2.0 引擎中是非必需的。

添加 Windows PowerShell 2.0 引擎功能

  • 服务器管理器中,从 管理 菜单中选择 添加角色和功能

    或者服务器 管理器,点击 “所有服务器”,右键点击服务器名称,然后选择 “添加角色和功能”。

  • 安装类型 页面,选择 基于角色或基于功能的安装

  • 功能 页面,展开 Windows PowerShell(已安装) 节点,选择 Windows PowerShell 2.0 引擎

有关启动 Windows PowerShell 2.0 引擎的信息,请参见 启动 Windows PowerShell 2.0 引擎

另请参阅