I am building a C # application until all it does is call the powershell get-process command.
I edited the csproj file to include System.Management.Automation
<ItemGroup> <Reference Include="System.Management.Automation" />
When launched locally (Windows 8.1 runs Powershell version 4), it works.
When running 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.
Cannot find System.Management.Automation Version = 3.0.0.0. I am fortunate that this will work on any version of Powershell and reference the local version
The Get-Process cmdlet runs on PS V2.
Is it possible to stop forcing version 3 of system automation automation? I read that you can do this in app.config, but there is no link to automate system management.
Thank you for your time.
----------------------------------------------- --- ---- EDIT ------------------------------------------ --- -
I managed to do this work, but installing the Target platform on .Net 3.5, however now it forces PS V2. Anyway, can I target the local version of the system management dll and force clients to use this version?
source share