Hi,
I’m using invoke-script to run a script from my dashboard and I’m wondering if anyone has gotten it to work to get “live” feedback from the output form the script so the user can see what the script are doing?
You could, in theory use Start-Transcript at the beginning and Stop-Transcript At the end to write output to a log, and implement an auto-updating text area in your dashboard.
That said, if you are just looking for debugging, I recommend checking out the universal extension for VSCode if you haven’t already, as that might fill some of those needs.
Ah, I see. I think the transcript may actually work for that. I’ve not tried it. Maybe @adam could shed some light on the terminal output built into the admin console, and whether it would be trivial to implement a similar component?
You can use Get-PSUJobOutput to receive output for a job from a dashboard. You could use the UDCodeEditor component to display that output. It’s the same component that we use in the admin console. Set-UDElement works with that component to set the code.
You could do something similar to this in your dashboard. It’s not a full working example but let me know if you need one.
I have tried that but I can’t get it to work, here is my code: The script are running fine but I don’t get any output in return and inside the admin portal I can see returns so it are writing returns
A couple changes that should help. Remove the Wait-UAJob so the script progresses past that point. Then loop every second until the job is completed and get the job output and set it to the code editor. Make sure to call Get-UAJob again to refresh the status of the job object.
Hi again,
I get this error when I’m trying the code it seems auth failure but I have tried with apptoken for admin user but still the same issue.
I have no trouble running the scripts from the dashboard it seem it’s only when I’m trying to get the output.
Hi again,
I get this error when I’m trying the code it seems auth failure but I have tried with apptoken for admin user but still the same issue.
I have no trouble running the scripts from the dashboard it seem it’s only when I’m trying to get the output.
@rbleattler Rob, here is a fixed link to the error message.
I just verified that this works for me. I’ve created an admin app token and am using Connect-PSUServer in my script to use that app token for the PSU cmdlets.
Is the code in this thread still more or less current, @adam? It works for me, but when the job finishes running I get a bunch of “Failed to query.NotFound” popups:
Ah! If I wrap the “Get-PSUJobOutput” in a try/catch I can suppress the popup! So that line is throwing a lot of exceptions that are being shown when the job finally completes. Any clue as to why that line would be throwing the “Failed to query.NotFound” exceptions for a running job? Anything I can do about that other than catching the exception?