Hello,
I would like to implement a form application which is hosting a PSHost and executes own cmdlets. As far as this it is no Problem.
But my form is using also other dlls and has instanciated objects from these dlls. Now I would like to access this methods from within my cmdlets.
How can this be done?
I will try to explain it with the following code snippets.
First the code implementing the form which is running the PSHost.
namespace MyApp { class MyAppForm { MyObject obj = new MyObject(); // this is the object I want to access later
PSHost pshost = new PSHost(); Runspace space; space = RunspaceFactory.CreateRunspace(pshost); space.Open(); Pipeline pipeline = space.CreatePipeline(<myCmdlet>); Collection<PSObject> results = pipeline.Invoke(); } }
And here is the cmdlet were I would like to access a method from within my form app.
namespace MyCmdlets { [Cmdlet(VerbsCommon.Verb, "Noun")] public class Verb_Noun : Cmdlet // parameters // overrides protected override void BeginProcessing() { // how can I get access to <obj> here? } }
Thanks
Alex