Crescendo
Crescendo copied to clipboard
Implement "trickle" parsing
Summary of the new feature / enhancement
As a user of a command that provides multiple outputs over time before finishing I'd like to be able to start parsing the output before the complete command has ended So that I can take action on certain statuses in the output
Proposed technical implementation details (optional)
I don't know how feasible this is though...
Start-Job {
<command args>
} -Name <command arg>
while ($job.state -ne 'Completed') {
$job = Get-Job -Name <command arg>
$job | Receive-Job
sleep -Milliseconds 400
}
Hi @DennisL68 -- thank you. PowerShell returns each object as quickly as the command sends it to the output. When there is a filter, job or sort - The command performing the sort holds the objects from the output, until it can complete the sort, then returns all the objects in the correct sort order. In the case of background jobs, you can get the results before the job has completed with receive-job, but I gather this is not the result you're after. For more information on PowerShell jobs, see https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_jobs?view=powershell-7.3#getting-the-results-of-a-job
Ok, what I'm having issues with in particular is psconfig.exe for SharePoint server. It takes a very long time to execute, and outputs various outputs, errors and statuses along the way.
I would like to have the option to abort the run on the first error detected by my parser, instead of having to wait for the "final" result until the end.
@DennisL68 -- after re-reading this - I would also suggest looking at the json property StreamOutput of the output handler. Set this to true and the output will stream to the handler. Here's an example: https://github.com/PowerShell/Crescendo/blob/master/Microsoft.PowerShell.Crescendo/Samples/ifconfig.crescendo.json
Yes, but...
MS SharePoint psconfig.exe doesn't provide json output...
I'm using my own parser function.
@DennisL68 If you look at the ifconfig example you'll see that it also doesn't provide json output by itself. It uses the jc and ConvertTo-Json commands. "Handler": "$input | jc --ifconfig | ConvertFrom-Json"
What is jc?
Judging by the syntax it seems to be some kind of Linux command?