Skip to content

Implement "trickle" parsing #194

Open

Description

@DennisL68

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
}

Activity

  1. added
    Issue-Enhancement
    on May 15, 2023
  2. theJasonHelmick commented on May 25, 2023

    @theJasonHelmick
    Collaborator

    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

  3. added
    Issue-Triaged
    Issue-Answered
    on May 25, 2023
  4. DennisL68 commented on May 25, 2023

    @DennisL68
    Author

    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.

  5. theJasonHelmick commented on Jun 1, 2023

    @theJasonHelmick
    Collaborator

    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

  6. DennisL68 commented on Jun 1, 2023

    @DennisL68
    Author

    Yes, but...

    MS SharePoint psconfig.exe doesn't provide json output...

    I'm using my own parser function.

  7. nlsdg commented on Aug 9, 2023

    @nlsdg

    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"

  8. DennisL68 commented on Aug 9, 2023

    @DennisL68
    Author

    What is jc?

    Judging by the syntax it seems to be some kind of Linux command?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-AnsweredIssue-EnhancementIssue-Triaged

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions