title: Calling PowerShell scripts from unmanaged C++
body: <p>Microsoft appears to be moving a lot of configuration and query capabilities to PowerShell (accessible from C# or managed C++), while deprecating and even removing older APIs (accessible for C or unmanaged C++). Those of us who have extensive unmanaged C++ programs that can't switch to managed C++ may have a need to call PowerShell cmdlets (at least, I have one now) -- how can we do so?</p>
  
  <p>There are suggestions that a reverse-PInvoke (managed/unmanaged thunking) might be able to do something, but I'm hoping for a better way than either thunking or parsing text output from a PowerShell script.</p>
  
  <p>[Note: This is a reworked and generalized <a href="https://stackoverflow.com/questions/489023/querying-exchange-2007-storage-group-database-details-with-unmanaged-c">query I made yesterday</a> that may have been too specialized.]</p>