My Software Notes

Useful things I discover

Adding PowerShell Automation to a .NET Application

with 3 comments

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.

Written by gsdwriter

August 28, 2012 at 3:46 pm

Posted in .NET, Powershell, Visual Studio

Tagged with ,

3 Responses

Subscribe to comments with RSS.

  1. Thank you very much!


    November 5, 2013 at 4:14 am

  2. Good Job! This is perect, I do not understand why this is such a pain.


    November 12, 2013 at 6:52 am

  3. Great tips. Solve my issue.

    Hkuko Neen

    September 26, 2014 at 12:57 pm

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

<span>%d</span> bloggers like this: