❔ C# Powershell, pipe one script to another?

Is it possible to run a script and pipe that result to another? The closest I find is something like this:
System.Management.Automation.PSDataCollection<System.Management.Automation.PSObject> res = null;
foreach (var item in this.tasks)
{
Console.WriteLine($"Executing script: {scripts[item.script].path}");
// add current script and parameters
ps.AddScript(scripts[item.script].script, true).AddParameters(item.parameters);
// check if we got a previous result
if (res is not null)
{
// check if the result has anything in it
if (res.Count > 0)
{
// add the previous result as an argument for the current script
// this seems to add the result to the first parameter of the same type
ps.AddArgument(res[0]);
}
}

// Execute script
res = await ps.InvokeAsync();
}
System.Management.Automation.PSDataCollection<System.Management.Automation.PSObject> res = null;
foreach (var item in this.tasks)
{
Console.WriteLine($"Executing script: {scripts[item.script].path}");
// add current script and parameters
ps.AddScript(scripts[item.script].script, true).AddParameters(item.parameters);
// check if we got a previous result
if (res is not null)
{
// check if the result has anything in it
if (res.Count > 0)
{
// add the previous result as an argument for the current script
// this seems to add the result to the first parameter of the same type
ps.AddArgument(res[0]);
}
}

// Execute script
res = await ps.InvokeAsync();
}
6 Replies
ffmpeg -i me -f null -
couldn't you pipe them by executing them in cmd? like "script1.ps1 | script2.ps1 | ..." ah no, you are the one of the powershell scripts job manager
Accord
Accord13mo ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Fjärilsmannen
Fjärilsmannen13mo ago
yeah, otherwise that suggestion would work, thanks though:)
ffmpeg -i me -f null -
is ps.AddArgument not working for you in some way?
Fjärilsmannen
Fjärilsmannen13mo ago
it doesn't seem to follow the position rules that strictly, so I don't know when i can actually trust it. It says it will use the parameter at position 0, but it seems to only care about that if it's the same type (i tested with int and string). If i know what rules it's working on then i would feel safer using it
Accord
Accord13mo ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server
More Posts
❔ Shadowsocks VPN clientHello, i am trying to build a shadowsocks vpn client so im not required to share any information ab[C# Winform with Sql Server] Error: 'Column named StdId cannot be found.Parameter name: columnName'Trying to select a row in Data Grid View in Winform C# and see the image to have an idea to my Table❔ WEB3. Get the the amount of tokenx I can buy with a certain amount of busd.I want to get the amount of tokenx I can buy with different inputs of busd. I have written out some ❔ Understanding reading values from binaryI'm reading a version number from the binary of a client via hex. However, I get different results w✅ Optimizing `HTTPClient.GetAsync()` and large stringsI am writing a client application that consumes a web API at a near real-time rate (100ms). I am usi❔ .NET Service discoveryI have a gRPC server installed on a workstation in an on-premise local network. And I have client apHow do you get the output type from a powershell script with System.Management.Automation?I am trying to figure out how to get the type specified in a powershell script `[OutputType([int])]`❔ Make interface deriving from another interface have a sealed implementation of a function...so that you dont have to write the same code for every child interface. details are in pastebin: ❔ Serialize objects from non-standard formatHello, I am trying to serialize objects from a non-standard format and dont know how to go about it ❔ Rider accepting completion deletes the next wordWhen I hit tab in Rider to accept a suggestion, it overwrites everything that comes after. Just like