我正在尝试在 Windows Server 2008 R2 机器上使用 Out-GridView cmdlet。它抱怨说它无法运行,因为我需要安装 Windows Powershell 集成脚本环境功能。问题是,它已经安装了。不确定问题是什么或如何解决此问题。
PS C:\Share\Jred\PowerShell> import-module servermanager
PS C:\Share\Jred\PowerShell> Get-WindowsFeature PowerShell-ISE
Display Name Name
------------ ----
[X] Windows PowerShell Integrated Scripting Environm... PowerShell-ISE
PS C:\Share\Jred\PowerShell> get-process | out-gridview
out-gridview : To use the Out-GridView cmdlet, install the Windows PowerShell Integrated Scripting Environment feature
from Server Manager. (Could not load file or assembly 'Microsoft.PowerShell.GraphicalHost, Version=1.0.0.0, Culture=neu
tral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.)
At line:1 char:27
+ get-process | out-gridview <<<<
+ CategoryInfo : ObjectNotFound: (Microsoft.Power...1bf3856ad364e35:AssemblyName) [Out-GridView], NotSupp
ortedException
+ FullyQualifiedErrorId : ErrorLoadingAssembly,Microsoft.PowerShell.Commands.OutGridViewCommand
PS C:\Share\Jred\PowerShell> Import-Module ServerManager; Add-WindowsFeature PowerShell-ISE
Success Restart Needed Exit Code Feature Result
------- -------------- --------- --------------
True No NoChan... {}
答案1
我按照以下步骤升级到 PowerShell 3.0:http://technet.microsoft.com/en-us/library/hh847837.aspx然后它就开始工作了。不知道为什么。