To reference PowerShell correctly, you must reference PowerShell inside the GAC. The PowerShell that is included with the Vista SDK is PowerShell V1.0, and this method will refer to 1.0, 2.0, or X.0, regardless of what is installed. The SDK assembly link will also not create the most portable of the projects, because you must have an SDK to build the project, and not just for Visual Studio and Windows.
Unfortunately, the link to the GAC elements is not something that the Visual Studio user interface does, so you need to manually edit the CSProj file. Find the section with the elements and add this reference element.
<Reference Include="System.Management.Automation" />
This will be a link to the latest version of System.Management.Automation installed on the system, regardless of its version.
Hope this helps
Start-Automating Dec 08 '09 at 20:10 2009-12-08 20:10
source share