title: Running a powershell script in memory
body: <p>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. </p>
  
  <p>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.</p>
  
  <p>These are my prerequisites:</p>
  
  <ul>
  <li>My assembly should be targeted to .NET 2.0 or .NET 3.5</li>
  <li>Always use the newest version of the powershell engine</li>
  <li>Run script in memory (it is a no-go to store the PS script temporarily on the hard disc)</li>
  </ul>
  
  <p>Any ideas?</p>