Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Windows Powershell SDK and System.Management.Automation.PSObject

I have a build error in a c sharp program that I am compiling in Visual Studio 2008 on a Windows Server (2008, I guess) SP 2 64-BIT OS. It says that 'System.Management.Automation.PSObject' is defined in an assembly that is not referenced. I did some searching in MSDN and I found that this seems to be part of 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 the Windows Powershell. If this is all I need, how do I make use of it or reference it in the C Sharp IDE. If I need to download something extra (ie the SDK), where do I go to do this and install it? I could not find anything online.

like image 630
xarzu Avatar asked Dec 08 '09 04:12

xarzu


People also ask

What is PSObject in PowerShell?

A PSObject is very much like a hashtable where data is stored in key-value pairs. You can create as many key-value pairs as you like for each PSObject .

What is System PowerShell?

PowerShell is a cross-platform task automation solution made up of a command-line shell, a scripting language, and a configuration management framework. PowerShell runs on Windows, Linux, and macOS.

Where is system management automation?

dll only in C:\Windows\Microsoft.NET\assembly\GAC_MSIL\System. Management. Automation/v4.


1 Answers

To correctly reference PowerShell, you should reference the PowerShell inside the GAC. The PowerShell included with the Vista SDK is PowerShell V1.0, and this technique will reference 1.0, 2.0, or X.0, whatever is installed. Referencing the SDK assembly will also not create the most portable of projects, because you have to have the SDK installed to build the project, rather than just Visual Studio and Windows.

Unfortunately, referencing GAC items is not something the visual studio UI does cleanly, so you have to go hand edit the CSProj file. Find the section with elements, and add this reference element.

<Reference Include="System.Management.Automation" />

This will reference the latest System.Management.Automation installed on the system, no matter what version it is.

Hope this helps

like image 121
Start-Automating Avatar answered Sep 29 '22 12:09

Start-Automating