Product: PowerShell Universal
Version: 2.8.x
Hi all,
Just wondering if someone has a good idea around this…
I have SQL jobs with multiple steps, each step kicks off a PowerShell script. These can run independently fine. I’ve created a PSU dashboard with a button that starts the SQL job. What I want to do is have a loading progress, and/or disable the start button for all users of the dashboard, until the SQL job has completed.
What would be the best way to attack this? At the moment I have the “current status” section (shown in below screenshot) as a dynamic element and updating that every 5 seconds based on another powershell script that checks the current status of the SQL job - sets cache:variables based on the SQL job status - then performs a Sync-UDElement
Cheers!
Steve.
I’ve set a new .ps1 file with some functions in it like StartSQLJob and SyncSQLInfo
The button calls the StartSQLJob function which updates some cache variables (like disable the button) then calle SyncSQLInfo once before checking the sql job status in a do loop until the run status changes then calls the SyncSQLInfo function which updates some cache variables and syncs the SQL Info element (shown in the screenshot) (Sync-UDElement).
This works fine for the person/session who initiates the running of the sql job, but if I have another browser window open on the same page the button state does update when the Sync-UDElement is called (it only updates on the page where the person clicked the ‘Run’ button).
Is there a way for Sync-UDElement to kinda do a broadcast sync and sync all the browser session where someone may have that particular dynamic element on the page they’re viewing?
The dynamic elements have an id of “$JobName`JobInfo” so I thought all browser session would have the same id and all update after running (Sync-UDElement -Id “$JobName`JobInfo”)
No doubt I’m missing something fundamental and someone will call me out on it - or I might be going around this in the completely wrong way. Keen to hear people’s suggestions!
Cheers!
Steve.
Would you be willing to share a version of this, i’m about to undertake a similar effort in powershell universal, it’d be amazing to get a head start.
You can use Sync-UDElement -Id 'name' -Broadcast
to send it to all users of the dashboard. You can use Sync-PSUComponent
from within a job or API to sync all connected users to all dashboards.
In this circumstance, I might recommend Sync-PSUComponent because even jobs run from the admin console would cause dashboards to reload.
^^^ From Adam on another thread, this works to update dynamic elements across all logged in people’s dashboards (where the element’s Id is the same)
@CaelFrost I posted a bunch of the code here: Broadcast update dynamic sections - #6 by pharnos (there might be something in there you can use?)