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


11

我在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

Answers:


5

这不可能。Windows Server 2008 R2中包含Windows PowerShell 2.0。您不能以任何受支持的方式在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

不,我在Window Web服务器2008 R2 sp1上,并且我仍然具有1.0 powershell,所以这就是我要寻找2.0,3.0的原因。我的帖子让我感到困惑。如果可以,请你帮助我。
Anirudha Gupta

2
我觉得你很困惑。Windows Server 2008 R2 SP1开箱即用包含Windows PowerShell 2.0。
Trevor Sullivan

3
是的,您明白了-路径仍然显示为v1.0。忽略:)
特雷弗·沙利文

1
查找正在使用的PowerShell版本的另一种方法是:$ PSVersionTable
Sean Perkins

6
这篇文章没有回答OP的问题,如何在Windows Server 2008 R2上升级PowerShell?
我说恢复莫妮卡

30

Server 2008 R2中包含PowerShell 2.0。Windows 8和Server 2012附带了PowerShell 3.0。可以在Server 2008 R2上安装PowerShell 3.0。

从该页面中摘录了以下说明:http : //technet.microsoft.com/zh-cn/library/hh847837.aspx

  1. 在安装Windows Management Framework 3.0之前,请卸载Windows Management Framework 3.0的所有早期版本。

  2. 从Microsoft下载中心(https://go.microsoft.com/fwlink/?LinkID=212547)安装Microsoft .NET Framework 4.0的完整安装(dotNetFx40_Full_setup.exe)。

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

  4. 从Microsoft下载中心(https://www.microsoft.com/zh-cn/download/details.aspx?id=34595)安装Windows Management Framework 3.0 。

该页面还描述了如何在Server 2008(非R2)和Windows 7上安装PowerShell 3.0。


3
当然,这应该是接受的答案。。。当前接受的答案仅指出了“ Powershell版本1.0”的错误……
真幸运,真是

1
链接technet.microsoft.com/en-us/library/hh847837.aspx已被重定向。重定向到的页面没有在Server 2008上安装PowerShell 3的信息。某些信息在此链接中:docs.microsoft.com/zh-cn/powershell/scripting/setup / ...
Mike Sherrill的“猫召回” “


2

首先,检查PowerShell版本的正确方法是检查变量$PSVersionTable.PSVersion,而不使用$ Host或Get-Host。

其次,您应该对应该在服务器上安装哪个版本的PowerShell进行一些研究,而不仅仅是将其更新为可用的最新版本。一个伟大的职位由脚本专家,我应该升级到最新的Windows PowerShell的版本?可以帮助您做出此决定。例如,该帖子指出,升级PowerShell可能会破坏重要的应用程序:

升级Windows PowerShell是否会破坏我的任何应用程序?不幸的是答案是可能的。Windows PowerShell 4.0发行说明提供了以下与Windows PowerShell 4.0不兼容的应用程序的列表:

  • System Center 2012 Configuration Manager(不包括SP1)
  • 系统中心虚拟机管理器2008 R2(包括SP1)
  • Microsoft Exchange Server 2013,Microsoft Exchange Server 2010和Microsoft Exchange Server 2007
  • Microsoft SharePoint 2013和Microsoft SharePoint 2010
  • Windows Small Business Server 2011标准版

如果您的计算机运行这些产品中的任何一种,请不要安装Windows PowerShell 4.0。Windows PowerShell 3.0具有非常相似的列表。其中一些应用程序(例如Exchange Server 2013)已与Service Pack兼容。您将需要确定Service Pack或其他修复程序是否可用于您的特定应用程序和情况。

此外,PowerShell的新版本也可能破坏您现有的脚本。


0

要保留当前版本,请说您仍在运行Windows Server 2008 R2,并且正在使用PowerShell 2.0。

在Windows PowerShell中运行以下代码:

Import-Module servermanager
Add-WindowsFeature powershell-ise

3
欢迎使用超级用户:请仔细阅读问题,它是“如何在Windows Server 2008 R2上升级PowerShell?” 您的答案“如何保留当前版本?” 而不是原始问题。它仍然很有价值,但是应该是一个评论,您还没有Rep,但是当您继续使用该网站时,它会得到它(不需要很长时间)。请花几分钟的时间,并宣读: - superuser.com/help .Answering:superuser.com/help/how-to-answer,再次欢迎superuser.Thankyou
mic84
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.