I would like to create the equivalent in C# of this:
PS > Get-Disk | Get-Partition
I've tried with this:
using (var r = RunspaceFactory.CreateRunspace())
{
var pipeline = r.CreatePipeline();
var gd = new Command("Get-Disk");
var gv = new Command("Get-Partition");
pipeline.Commands.Add(gp);
pipeline.Commands.Add(gv);
var results = pipeline.Invoke()
}
But this is not sync. I would like to create the pipeline and read from it asynchronously. Is it possible?
Thank you!
NOTE: This is related, but not async: How pipe powershell commands in c#