You might want to check out PowerSE (http://www.powerse.com), for free. But there is also an OEM version that allows you to connect to the editor to edit / debug PowerShell commands. then return the command text for storage and execution in the context of your application.
source share