I am building a application in C#, so far all it does is call the "get-process" powershell command.
I have edited the csproj file to include System.Management.Automation
<ItemGroup>
<Reference Include="System.Management.Automation" />
When run locally (Windows 8.1 running Powershell version 4) it works.
When run on a remote Windows 7 machine with Powershell version 2, the program throws an exception
System.IO.FileNotFoundException: Could not load file or assembly 'System.Management.Automation, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.
It cannot find System.Management.Automation Version=3.0.0.0. I was lead to believe that this would work on any version of Powershell and reference the local version
The cmdlet Get-Process does work on PS V2.
Is it possible to stop forcing version 3 of system management automation? I've read you can do this in the app.config but there is no reference to system management automation.
Thankyou for your time.
------------------------------------------------------ EDIT -----------------------------------------------
I was able to make this work but setting the Target framework to .Net 3.5, however this now forces PS V2. Is there anyway I can target the local version of the system management dll and make clients use that version?
Powershell 2.0 does not include System.Management.Automation V3. System.Management.Automation is provided by Windows Management Framework Core, not .Net. If you've got Powershell 2.0, you do not have Automation 3.0. For a list of what files/assemblies are provided in Powershell 2.0 visit the following site:
Windows Management Framework (Windows PowerShell 2.0, WinRM 2.0, and BITS 4.0)
Upgrade to Powershell 4.0 by installing WMF 4.0 from Microsoft on the target machine.
http://www.microsoft.com/en-us/download/details.aspx?id=40855
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