Windows Powershell SDK and System.Management.Automation.PSObject

I have a build error in an acute program that I am compiling in Visual Studio 2008 on Windows Server (2008, I think) SP 2 64-BIT OS. It says that "System.Management.Automation.PSObject" is defined in an assembly that is not referenced. I did a few searches on MSDN, and I found this to be similar to the Windows Power Shell SDK. http://msdn.microsoft.com/en-us/library/system.management.automation.psobject(VS.85).aspx

The problem is that I already have Windows Powershell. If that's all I need, how to use it or reference it in the C Sharp IDE. If I need to download something additional (i.e. SDK), where can I do it and install it? I did not find anything on the Internet.

+9
c # windows powershell sdk
Dec 08 '09 at 4:14
source share
3 answers

Take a look at C:\Program Files\Reference Assemblies\Microsoft\WindowsPowerShell\v1.0 for System.Management.Automation.dll, and if it exists, add it as a link to your C # project. If it does not exist, download the Windows SDK , which will put the file in the specified location.

+14
Dec 08 '09 at 4:48
source share
— -

If you cannot find it there, enter it at the PowerShell prompt.

 Copy ([PSObject].Assembly.Location) ~/Desktop 
+34
Dec 08 '09 at 4:53
source share

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

+13
Dec 08 '09 at 20:10
source share



All Articles