Background
- PowerShell 3 with SDK
- C# with Framework 4.5
Implementation
I have implemented my own PSHost alogn with PSHostUserInterface. In PSHostUserInterface I override all Write... methods and colleting the to one variable which serves the output.
Problem
In my application I calling Cmdlets which use WriteObject as their output. In the PSHostUserInterface.Write... methods I am getting everything but these WriteObject's output. For example, I see this in regular PowerShell:
This is sample string output from the command
Here we have object from Cmdlet.WriteObject function
This is another string output from the command
This is what I get in my custom PSHost in my application:
This is sample string output from the command
This is another string output from the command
Question
How can I get in C# all the outputs of the Cmdlet?
Many thanks
Pipeline.Invokeis an enumerable over the output from the pipeline (for error output use theErrorproperty of the samePipelineinstance). So please update your question with the code you are using to execute PSH pipelines in your host.Errorin the pipeline at all. I cannot just simplyPipeline.Invokeas my CmdLets requires UI. Because of that doing it through customPSHost,PSHostUserInterfacewhere I can override user interaction and execute them.