如何在 Windows Server 2008 R2 上升級 PowerShell?

如何在 Windows Server 2008 R2 上升級 PowerShell?

我在 Windows Server 2008 R2 中使用 Windows PowerShell 1.0。我在 Windows 8 中嘗試過 PowerShell 3.0,它對我來說看起來不錯。

現在的問題是:如何在 Windows Server 2008 R2 電腦上升級 PowerShell?如果我無法使用 3.0,那麼有什麼方法可以升級到最新的可用版本嗎?


Name             : ConsoleHost
Version          : 2.0
InstanceId       : f0b6480c-be55-429d-a197-65604de5887e
UI               : System.Management.Automation.Internal.Host.InternalHostUserInterface
CurrentCulture   : en-US
CurrentUICulture : en-US
PrivateData      : Microsoft.PowerShell.ConsoleHost+ConsoleColorProxy
IsRunspacePushed : False
Runspace         : System.Management.Automation.Runspaces.LocalRunspace

答案1

這不可能。 Windows PowerShell 2.0 包含在 Windows Server 2008 R2 中。您無法以任何受支援的方式在 2008 R2 中安裝 Windows PowerShell 1.0。

若要驗證您正在執行的 PowerShell 版本,只需回顯該$host變數即可。

Name             : Windows PowerShell ISE Host
Version          : 3.0
InstanceId       : 711f19be-3f19-4612-bea3-61899c1a73c2
UI               : System.Management.Automation.Internal.Host.InternalHostUserInterface
CurrentCulture   : en-US
CurrentUICulture : en-US
PrivateData      : Microsoft.PowerShell.Host.ISE.ISEOptions
IsRunspacePushed : False
Runspace         : System.Management.Automation.Runspaces.LocalRunspace

答案2

PowerShell 2.0 包含在 Server 2008 R2 中。 PowerShell 3.0 包含在 Windows 8 和 Server 2012 中。

以下說明摘自此頁面:http://technet.microsoft.com/en-us/library/hh847837.aspx

  1. 在安裝 Windows Management Framework 3.0 之前,請先解除安裝任何先前版本的 Windows Management Framework 3.0。

  2. 從 Microsoft 下載中心安裝 Microsoft .NET Framework 4.0 (dotNetFx40_Full_setup.exe) 的完整安裝,網址為https://go.microsoft.com/fwlink/?LinkID=212547

  3. 或者,從 Microsoft 下載中心安裝 Microsoft .NET Framework 4.5 (dotNetFx45_Full_setup.exe):https://go.microsoft.com/fwlink/?LinkID=242919

  4. 從 Microsoft 下載中心安裝 Windows Management Framework 3.0,網址為https://www.microsoft.com/en-us/download/details.aspx?id=34595

該頁面也介紹如何在 Server 2008(非 R2)和 Windows 7 上安裝 PowerShell 3.0。

答案3

電源外殼4.0是 Windows Server 2008 R2 的最終版本。

先決條件是:

它作為以下部分安裝Windows管理框架4.0

答案4

若要保留目前版本,假設您仍在執行 Windows Server 2008 R2 並使用 PowerShell 2.0。

在 Windows PowerShell 中執行以下程式碼:

Import-Module servermanager
Add-WindowsFeature powershell-ise

相關內容