Get the output from script "live" in dashboard?

Just on this one, @adam - it’d be super cool if there was a built-in dashboard component that was essentially the same as the “job output” panel when you execute a script. I’m not sure how it would work, but being able to show the live output of a job without having to write the above code would be really nice.

1 Like

I can open an issue for this. I think enough people have tried to do this to warrant a component.

4 Likes

Did you ever get to this one, @adam? I’m revisiting a dashboard that shows job output “live”, and wondering if there’s a built-in way to do this now.

This hasn’t been implemented yet.

1 Like

This would definately be great, would be nice if it also honored -foregroundcolor aswell on any write-host commands

Real time output / updating on a script would be really handy

Regards

Rhys

Edited, i worked out my issue, in debugging i had been bypassng the params on the actual script

leaving the below code as it might help someone with this in the future

New-UDButton -Text 'Deploy Proofpoint' -OnClick {
    Set-UDElement -Id 'btnDeployProofpoint' -Properties @{
        disabled = $true 
        text = "Deploying Proofpoint"
    }

    $AppToken = 'My App Sevret'

    Connect-PSUServer -ComputerName http://localhost:5000 -AppToken $AppToken

    $Job = Invoke-PSUScript -Script 'Deploy-Proofpoint-Essentials.ps1' -CompanyName $($EventData.Context.CompanyName)

    while($Job.Status -ne 'Completed')
    {
        Start-Sleep 1
        $Output = (Get-PSUJobOutput -Job $Job).Data -join ([Environment]::NewLine)
        Set-UDElement -Id 'codeEditor' -Properties @{
            code = $Output 
        }

        $Job = Get-PSUJob -Id $Job.Id
    }

    Set-UDElement -Id 'btnDeployProofpoint' -Properties @{
        disabled = $true 
        text = "Job Completed"
    }

} -Id 'btnDeployProofpoint'
New-UDCodeEditor -Id 'codeEditor' -ReadOnly -Height 500

PS. really loving your product i wish i found PowerShell Universal a long time ago.

Thanks

Rhys

2 Likes

@adam While I have your code working and it works well showing the script output, I have an issue where it shows the output of a previous job if I run a secondary script without first refreshing my browser.

I’m believe it has something to do with sessions and not clearing session info between running different scripts but i don’t know what I’m missing, essentially the first script I run the output window is clear and it gets live view as the script runs

if I then go to a different script and run it the output windows flickers with all the previous output for the first job/script

If this doesn’t make sense let me know and ill create a screen recording

Is there something I should have in each of my scripts or UD Pages that clears this session data each time a page is loaded?

Thanks

Rhys

Can you share a screen recording? I’m not quite understanding.

Where are we at with this? Is anyone doing something like this today?

Even better yet, I think it would be really nice to have the ability to view something as we see with “write-progress” in the jobs section when a job is running.

Something like this would give the user a bit more feedback for those longer running processes.

I know this product is always being modified and updated. But yeah as for a progress bar that would only work if you kind of defined the start and end of your script…there is a component which is built in which can display loading progress. It’s been a while since I built a component but if I can find one…or if others can post links to an existing component happy to have a go