Updating forms while running a Job

Ask questions about creating Graphical User Interfaces (GUI) in PowerShell and using WinForms controls.
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Locked
User avatar
brianclark
Posts: 12
Last visit: Fri May 21, 2021 5:15 pm

Updating forms while running a Job

Post by brianclark »

I have a job that runs using the Jobtracker, and has multiple parts to said job.
I have read, and used the jobtracker quite a bit, however I am still a bit uneducated as to how to update fields of a form while a Job is in progress.
For example, I have an entire task that runs in one Jobscript of the jobtracker to rename a cluster shared volume in failover cluster manager, as well as rename the volume label. That task is then broken down into sub-tasks within the scriptblock;
1. Get the cluster shared volume based on Variables passed in.
2. Get the volume information based on the information returned in #1
3. Update fields (Log window textbox) on the form with information provided from the items above.
4. Rename volume in Failover Cluster Manager
5. Update (log window textbox) of completed task, or failure.
6. Rename the volume label on the specific host
7. Update (log window textbox) of completed task or failure.
8. CompletedScript runs.

Is there a way to update textboxes in the main GUI with completed task information while the script is running? I am assuming this would use the "UpdateScript block, however I don't really understand how that would work.

jvierra
Posts: 14882
Last visit: Sat Jul 31, 2021 1:48 am
Answers: 12
Has voted: 3 times
Been upvoted: 10 times

Re: Updating forms while running a Job

Post by jvierra »

Everything returned from the scriptblock is read in the UpdateScript block. Look at the initial example form provided as a form type. It demonstrates what is happening.

User avatar
brianclark
Posts: 12
Last visit: Fri May 21, 2021 5:15 pm

Re: Updating forms while running a Job

Post by brianclark »

Thanks for the reply. I will take another look at that and get back if anything is unclear.

Locked