I just put together a quick little example of how to host PowerShell inside your own application, but to make it more useful I built it as an extension method so that you can basically call ToPowerShell(…) on any object. If the object happens to implement IEnumerable then there is an alternative ToPowerShell(…) which allows you to specify whether to enumerate the items.
Download the sample if you are interested.
Pingback: PowerShell, as an extension method! - Rod Trent at myITforum.com
Pingback: Development in a Blink » Blog Archive » PowerShell as an Extension Method
Thanks for sharing, Mitch!
I always forget how Powershell can be used inside applications… I’ll have to do some more investigating, as there’s a few major applications at work I’d like to go the other way with – provide a way to script/automate into them via Powershell, so I can script common jobs or provide ways to iterate data, etc, without needing to add things to our application.
Thanks for the pointers, and hope you’re having a great holiday period.
Andrew