Adding PowerShell Automation to a .NET Application
So I want to add PowerShell automation to my .NET app and according to MSDN (How to Write a Simple Host Application) I have to use the “Browse” feature of the “Add Reference” dialog in Visual Studio. The location for the System.Management.Automation.dll is given as “Windows\assembly\GAC_MSIL\System.Management.Automation”. But that may not always be correct. See my note at the end.
Another, and I think better, way to do it is to open your project file and in the first “<ItemGroup>” section, add:
<Reference Include="System.Management.Automation" />
This worked great for me.
Something to watch out for if you use the “Browse” method and you are using the Powershell 3 CTP: The dll is in a different location:
When I used the “Reference” method, Visual Studio referenced it without me having to do anything more. Now that’s what I call service.