No PowerShell in System.Management.Automation?

吃可爱长大的小学妹 提交于 2019-12-24 07:07:24

问题


I'm having trouble getting the PowerShell class to resolve. I'm following along with the example in this question.

I have a reference added to System.Management.Automation from C:\Program Files\Reference Assemblies\Microsoft\WindowsPowerShell\v1.0\System.Management.Automation.dll

I have using System.Management.Automation; included at the top of my class.

However, when I try to create an instance of powershell: PowerShell ps = PowerShell.Create(), PowerShell won't resolve.

Using ctrl+. to auto-add the fully-qualified namespace (or using statement) just suggests Microsoft.Powershell in place of PowerShell.

I'm very confused why this is happening as even the example included in the MSDN documentation on the PowerShell class has pretty much exactly what I have.

I am in .NET 3.5, Visual Studio 2010, and Windows Server 2008 R2


回答1:


The PowerShell class is new to PowerShell 2.0. Make sure you're referencing the 2.0 version of SMA.dll. Do you have PowerShell 2.0 installed?



来源:https://stackoverflow.com/questions/17051184/no-powershell-in-system-management-automation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!