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.
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 .
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.
dll only in C:\Windows\Microsoft.NET\assembly\GAC_MSIL\System. Management. Automation/v4.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With