Okay, so all I simply want to do is write some .NET Managed Code to run reports against my Xendesktop 4.0 and 5.0 environments. When i attempt to add the System.Management.Automation assembly from my .NET compliler, I get the following message. Namespace or type specified in the Imports ‘System.Management.Automation’ doesn’t contain any public member or cannot be found. Make sure the namespace or the type is defined and contains at least one public member. Make sure the imported element name doesn’t use any aliases.
I have already confirmed Powershell 1 or 2 is currently installed in my Development Environment, and I have at least .NET Service Pack 3.5 installed as well. I also have added a reference to System.Management. Now all I need to do is get my compiler to recognize this specific namespace. Fear no more, here is a quick way to get this minor issue resolved.
For starts, here is what my code looks like.

Just to confirm, lets make sure you ahve added a reference to System.Management. To do so, right click on your project and select “Add Reference”. Click on the .NET tab and highlight the System.Management Component and select OK to proceed. You can see, in this scenario, we are using the .NET 4.0.0.0 Framework. (see capture below)

With the system.management reference successfully added and confirmed, go ahead and save your project and exit visual studio.
Now with the compiler closed, open your Project File in notepad.
Search for <Reference Include=”System.Management” />, which should be located under <ItemGroup> and replace with <Reference Include=”System.Management.Automation” />, then save your Project file and reopen in visual studio.
Example Before:

Example After:

Once you open your project, you can see system.management.automation is now available for you to utilize.

By performing the above few steps, you will also be able to add references to System.Management.Automation.Runspaces, as well as several others.