Hi Everyone,
Need some help/understanding of the blog I read on this site here https://www.sapien.com/blog/2012/05/16/ ... ive-forms/
Now according to this blog, using the "Add-JobTracker" I can add a job. When I add my scriptblock, it works like a charm. However, I don't understand how I can add a foreach block that has 20 scriptblocks and pass that to the add-Jobtracker part and also update the progressbar with this.
I thought of calling the Add-jobtracker one by one but that would not only defeat the purpose of this blog but that would complicate the progressbar.
Anyone can explain how to accomplish this? Am I on the wrong path or didn't get the blog at all?
I added a modified downloaded project to what I'm asking and attached here.
Thanks in advance.
--------------------------------------
PowerShell Studio 2016 5.2.124
Version of product: 64
Operating system: Windows 7
OS: 64 bit
Help with the responsive form
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.
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.
Re: Help with the responsive form
Why would you add 20 scripts to the same job? That makes no sense. Are you saying you want to create 20 separate jobs? Just add the jobs one at a time. JobTracker will manage multiple jobs.
If you have 20 steps and you want them to run parallel as one job then use a workflow and add that as a job.
If you have 20 steps and you want them to run parallel as one job then use a workflow and add that as a job.
Re: Help with the responsive form
I have about 20 scripts that copies different things. Some are files as little as 10kb but some are as big as 10gb. What I'm trying to do is run everything at once without freezing the GUI but update the progress bar step as the small files complete.
I've been looking around, saw lots of examples but couldn't actually find one that explains what I'm trying to do.
Any ideas?
I've been looking around, saw lots of examples but couldn't actually find one that explains what I'm trying to do.
Any ideas?
Re: Help with the responsive form
Hi jvierra,
Can you give me an example on how to add multiple jobs? I'm looking at the functions and don't see how that can be accomplished.
in a very simple example I tried doing :
foreach($i in $alljobs)
{
Add-jobtracker -scriptblock {$i}
}
which didn't work.
Can you give me an example on how to add multiple jobs? I'm looking at the functions and don't see how that can be accomplished.
in a very simple example I tried doing :
foreach($i in $alljobs)
{
Add-jobtracker -scriptblock {$i}
}
which didn't work.
Re: Help with the responsive form
I get that. Thanks!
but that didn't update progressbar correctly. after the first script, it just completes as 100% as I mentioned in my initial post.
but that didn't update progressbar correctly. after the first script, it just completes as 100% as I mentioned in my initial post.
Re: Help with the responsive form
You will need to be sure the Update script runs for all jobs and that the progress steps are set correctly as well as the initial value. This will require using arithmetic and some serious design thinking to adapt the tracker to your requirements.
Re: Help with the responsive form
So here is what I got so far...
I have a listview. So the folder gets copied over, but I can't update the subitem to either "Success" or "Error".
Any ideas what could be causing this issue?
Thanks in advance!
I have a listview. So the folder gets copied over, but I can't update the subitem to either "Success" or "Error".
Any ideas what could be causing this issue?
Thanks in advance!
Code: Select all
$Test = $listview.Items.Add("Copying Folder")
if (Test-Path "C:\Temp\From")
{
$Test.Subitems.Add("Folder exists")
$Test.Subitems.Add("Copying...")
Add-JobTracker -Name "Test" `
-JobScript $sb -ArgumentList "C:\Temp\From", 'C:\test' `
-CompletedScript {
Param ($job)
$Compare = CompareFolderSize "C:\Temp\From" 'C:\test'
if ($Compare -eq $true)
{
$Test.Subitems[2].Text = "Success"
}
else
{
$Test.Subitems[2].Text = "Error"
}
}` -UpdateScript {
Param ($job)
while (Get-job -State "Running" | Where-Object{ $_.Name.Contains("Test") })
{
$Test.Subitems[2].Text = "Still Copying"
}
}
}
else
{
$copyError = "ERROR - Check folder or file"
$Test.Subitems.Add($copyError)
}
Re: Help with the responsive form
For this it would be easier to use a DataGridView,
In the update script you need to get a copy of the list item. The one you have is out of scope when the timer tick runs the "Update" block.
This should work although I would use a better name:
$global:Test =$listview.Items.Add("Copying Folder")
I would use:
$global:g_CurrentItem=$listview.Items.Add("Copying Folder")
In the update script you need to get a copy of the list item. The one you have is out of scope when the timer tick runs the "Update" block.
This should work although I would use a better name:
$global:Test =$listview.Items.Add("Copying Folder")
I would use:
$global:g_CurrentItem=$listview.Items.Add("Copying Folder")