问题
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