I am searching for a way on how to run a powershell script in C# in memory using the newest powershell engine found on the system. Currently I use the Microsoft Windows PowerShell Engine Core Assembly (System.Management.Automation) which works perfect for powershell scripts using the powershell version 2.0 engine.
My goal is the create a .NET 2.0 or 3.5 assembly which calls powershell scripts in memory using the newest powershell engine found on the system. This could be version 2 or 3.
These are my prerequisites:
- My assembly should be targeted to .NET 2.0 or .NET 3.5
- Always use the newest version of the powershell engine
- Run script in memory (it is a no-go to store the PS script temporarily on the hard disc)
Any ideas?