{"id":132,"date":"2011-02-04T17:47:50","date_gmt":"2011-02-05T00:47:50","guid":{"rendered":"http:\/\/ryan.witschger.net\/?p=132"},"modified":"2011-02-04T17:47:50","modified_gmt":"2011-02-05T00:47:50","slug":"getting-the-progress-of-a-child-thread-in-powershell","status":"publish","type":"post","link":"http:\/\/www.Get-Blog.com\/?p=132","title":{"rendered":"Getting the Progress of a Child Thread in PowerShell"},"content":{"rendered":"<p>My most popular article has thus far been the post over multithreading found <a href=\"http:\/\/ryan.witschger.net\/?p=22\">here<\/a>.  As such I felt that my audience might like to see some more entries covering that topic.  After all, it is a vast topic with a lot of very advanced things you can do.  In this post I would like to talk about tracking the status of your various threads.  In other words, how can you see a progress of what your child script is doing?<\/p>\n<p>In exploring this myself, I worked with passing custom objects back to the parent which held various status messages that the parent could read in with the &#8220;receive-job&#8221; command.  That actually worked, but it took a lot of code in both the parent and the child to generate and read the status from the child threads.<\/p>\n<p>While working with this, though, I found that the Job object from &#8220;get-job&#8221;, a System.Management.Automation.Job, has a property called &#8220;Progress&#8221;.  I then decided to look into how this actually gets filled out.  And the answer eluded my research until I managed to do it, completely by accident.  As it turns out, this very useful property is filled in automatically by a &#8220;write-progress&#8221; command run within the child thread.  It is actually quite logical that the progress field is filled in by &#8220;write-progress&#8221;.<\/p>\n<p>So, that is enough of a background on how I came about it.  Let&#8217;s actually look at some code.  First,I want to create a script block to run within my child job.<\/p>\n<div class=\"codecolorer-container powershell solarized-dark\" style=\"overflow:auto;white-space:nowrap;width:680px;\"><div class=\"powershell codecolorer\"><span class=\"co1\">## Write some code for the child threads to execute<\/span><br \/>\n<span class=\"re0\">$ThreadCode<\/span> <span class=\"sy0\">=<\/span> <span class=\"br0\">&#123;<\/span><br \/>\n&nbsp; &nbsp; <span class=\"re0\">$x<\/span> <span class=\"sy0\">=<\/span> <span class=\"nu0\">0<\/span><br \/>\n&nbsp; &nbsp; <span class=\"re0\">$time<\/span> <span class=\"sy0\">=<\/span> <span class=\"nu0\">200<\/span><br \/>\n&nbsp; &nbsp; <span class=\"kw3\">While<\/span> <span class=\"br0\">&#40;<\/span><span class=\"re0\">$x<\/span> <span class=\"kw4\">-lt<\/span> <span class=\"nu0\">100<\/span><span class=\"br0\">&#41;<\/span><span class=\"br0\">&#123;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; <span class=\"re0\">$x<\/span><span class=\"sy0\">++<\/span><br \/>\n<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; <span class=\"kw1\">Write-Progress<\/span> &nbsp;<span class=\"kw5\">-Activity<\/span> <span class=\"st0\">&quot;Testing&quot;<\/span> <br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class=\"kw5\">-Status<\/span> <span class=\"st0\">&quot;Testing&quot;<\/span> <br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class=\"kw5\">-PercentComplete<\/span> <span class=\"re0\">$X<\/span> <br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class=\"kw5\">-completed<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; <span class=\"kw1\">Start-Sleep<\/span> <span class=\"kw5\">-Milliseconds<\/span> <span class=\"re0\">$time<\/span><br \/>\n&nbsp; &nbsp; <span class=\"br0\">&#125;<\/span><br \/>\n&nbsp; &nbsp; <span class=\"kw1\">Write-Progress<\/span> &nbsp;<span class=\"kw5\">-Activity<\/span> <span class=\"st0\">&quot;Testing&quot;<\/span> <br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class=\"kw5\">-Status<\/span> <span class=\"st0\">&quot;Testing&quot;<\/span> <br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class=\"kw5\">-PercentComplete<\/span> <span class=\"nu0\">100<\/span> <br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class=\"kw5\">-Completed<\/span><br \/>\n&nbsp; &nbsp; <span class=\"st0\">&quot;Annnd we're done.&quot;<\/span><br \/>\n<span class=\"br0\">&#125;<\/span><\/div><\/div>\n<p>So here you&#8217;ll notice that I am basically creating a loop that will count 1 to 100 and then close.  Along the way it will fill out its progress with the &#8220;write-progress&#8221; cmdlet.  The one important note is that I am adding the &#8220;-completed&#8221; parameter to the &#8220;write-progress&#8221; cmdlet.  That may look like a mistake in the code,but it isn&#8217;t.  If you play around with this manner of getting progress from a child you will notice that when you run a &#8220;receive-job&#8221; your host thread will read all output from the child, including flashing all of the &#8220;write-progress&#8221; bars that were in the child.  If you actually read the help files for &#8220;write-progress&#8221;, you&#8217;ll see that actual description of the functionality of &#8220;-complete&#8221; states that is simply hides the output bar.  We need to do this so that when the parent thread runs a &#8220;receive-job&#8221; there is no odd behavior for the end user.<\/p>\n<div class=\"codecolorer-container powershell solarized-dark\" style=\"overflow:auto;white-space:nowrap;width:680px;\"><div class=\"powershell codecolorer\"><span class=\"co1\">## Kill any current jobs in the sessions and get rid of them<\/span><br \/>\nGet<span class=\"sy0\">-<\/span>Job <span class=\"sy0\">|<\/span> Stop<span class=\"sy0\">-<\/span>Job<br \/>\nGet<span class=\"sy0\">-<\/span>Job <span class=\"sy0\">|<\/span> Remove<span class=\"sy0\">-<\/span>Job<br \/>\n<br \/>\n<span class=\"co1\">## Start the child job and assign to a variable to save some code later<\/span><br \/>\n<span class=\"re0\">$Job<\/span> <span class=\"sy0\">=<\/span> Start<span class=\"sy0\">-<\/span>Job <span class=\"sy0\">-<\/span>ScriptBlock $ThreadCode<\/div><\/div>\n<p>So for this quick snippet we are just closing an remove any jobs our current session may have, and then starting our job.  I assign it to a variable so we don&#8217;t have to track it down later, not that it&#8217;s hard.<\/p>\n<div class=\"codecolorer-container powershell solarized-dark\" style=\"overflow:auto;white-space:nowrap;width:680px;\"><div class=\"powershell codecolorer\"><span class=\"kw3\">While<\/span> <span class=\"br0\">&#40;<\/span><span class=\"re0\">$Job<\/span>.State <span class=\"kw4\">-eq<\/span> <span class=\"st0\">&quot;Running&quot;<\/span><span class=\"br0\">&#41;<\/span><span class=\"br0\">&#123;<\/span><br \/>\n&nbsp; &nbsp; <span class=\"co1\">## Get the Child job object<\/span><br \/>\n&nbsp; &nbsp; <span class=\"re0\">$Child<\/span> <span class=\"sy0\">=<\/span> <span class=\"re0\">$Job<\/span>.ChildJobs<span class=\"br0\">&#91;<\/span><span class=\"nu0\">0<\/span><span class=\"br0\">&#93;<\/span><br \/>\n&nbsp; &nbsp; <br \/>\n&nbsp; &nbsp; <span class=\"co1\">## Get the newest Progress Object in the child job<\/span><br \/>\n&nbsp; &nbsp; <span class=\"re0\">$Progress<\/span> <span class=\"sy0\">=<\/span> <span class=\"re0\">$Child<\/span>.Progress<span class=\"br0\">&#91;<\/span><span class=\"re0\">$Child<\/span>.Progress.Count <span class=\"sy0\">-<\/span> <span class=\"nu0\">1<\/span><span class=\"br0\">&#93;<\/span><br \/>\n<br \/>\n&nbsp; &nbsp; <span class=\"co1\">## If the progress object is not null<\/span><br \/>\n&nbsp; &nbsp; <span class=\"kw3\">If<\/span> <span class=\"br0\">&#40;<\/span><span class=\"re0\">$Progress<\/span>.Activity <span class=\"kw4\">-ne<\/span> <span class=\"re0\">$Null<\/span><span class=\"br0\">&#41;<\/span><span class=\"br0\">&#123;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; <span class=\"kw1\">Write-Progress<\/span> &nbsp;<span class=\"kw5\">-Activity<\/span> <span class=\"re0\">$Job<\/span>.Name <br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class=\"kw5\">-Status<\/span> <span class=\"re0\">$Progress<\/span>.StatusDescription <br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class=\"kw5\">-PercentComplete<\/span> <span class=\"re0\">$Progress<\/span>.PercentComplete <br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class=\"kw5\">-ID<\/span> <span class=\"re0\">$Job<\/span>.ID<br \/>\n&nbsp; &nbsp; <span class=\"br0\">&#125;<\/span><br \/>\n&nbsp; &nbsp; <br \/>\n&nbsp; &nbsp; <span class=\"kw1\">Start-Sleep<\/span> <span class=\"kw5\">-Milliseconds<\/span> <span class=\"nu0\">200<\/span><br \/>\n<span class=\"br0\">&#125;<\/span><\/div><\/div>\n<p>So this is the bread and butter of the parent script.  It simply loops around as long as our job is running.  First we need to find the child job to our parent job.  I am not sure why Microsoft chose to design it like this, but each job you start actually runs commands in a child job.  I have a feeling it has something to do with functionality with Windows HPC, but that is neither here nor there.  Once we have our child job, we want to find the latest progress object that has been passed.  After that I just check to see if the object is empty, because the first check may not have given the child thread enough time to fill this out.  If there is data, then we can fill out a &#8220;write-progress&#8221; bar on our host thread.  From there we just repeat until the job is done.<\/p>\n<div class=\"codecolorer-container powershell solarized-dark\" style=\"overflow:auto;white-space:nowrap;width:680px;\"><div class=\"powershell codecolorer\">Get<span class=\"sy0\">-<\/span>Job <span class=\"sy0\">|<\/span> Receive<span class=\"sy0\">-<\/span>Job<\/div><\/div>\n<p>At the end we just want to read anything the child script may actually have sent.  So that covers it.  It is really easy to get custom progress bars for a child process because there is a good, built in method to do it.<\/p>\n<p>Following is a full example of a script which will launch three child threads at a time until there have been 10 opened total.  It will show you the output of each thread as it completes and the progress bars produced by each.  I even included a random speed that each child will complete so you can see some bells and whistles going.<\/p>\n<div class=\"codecolorer-container powershell solarized-dark\" style=\"overflow:auto;white-space:nowrap;width:680px;height:300px;\"><div class=\"powershell codecolorer\"><span class=\"co1\">## Write some code for the child threads to execute<\/span><br \/>\n<span class=\"re0\">$ThreadCode<\/span> <span class=\"sy0\">=<\/span> <span class=\"br0\">&#123;<\/span><br \/>\n&nbsp; &nbsp; <span class=\"re0\">$x<\/span> <span class=\"sy0\">=<\/span> <span class=\"nu0\">0<\/span><br \/>\n&nbsp; &nbsp; <span class=\"re0\">$time<\/span> <span class=\"sy0\">=<\/span> Get<span class=\"sy0\">-<\/span>Random <span class=\"kw5\">-Maximum<\/span> <span class=\"nu0\">200<\/span> <span class=\"sy0\">-<\/span>SetSeed $<span class=\"br0\">&#40;<\/span><span class=\"kw1\">Get-Date<\/span><span class=\"br0\">&#41;<\/span>.Millisecond<br \/>\n&nbsp; &nbsp; <span class=\"kw3\">While<\/span> <span class=\"br0\">&#40;<\/span><span class=\"re0\">$x<\/span> <span class=\"kw4\">-lt<\/span> <span class=\"nu0\">100<\/span><span class=\"br0\">&#41;<\/span><span class=\"br0\">&#123;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; <span class=\"re0\">$x<\/span><span class=\"sy0\">++<\/span><br \/>\n<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; <span class=\"kw1\">Write-Progress<\/span> <span class=\"kw5\">-Activity<\/span> <span class=\"st0\">&quot;Testing&quot;<\/span> <span class=\"kw5\">-Status<\/span> <span class=\"st0\">&quot;Testing&quot;<\/span> <span class=\"kw5\">-PercentComplete<\/span> <span class=\"re0\">$X<\/span> <span class=\"kw5\">-completed<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; <span class=\"kw1\">Start-Sleep<\/span> <span class=\"kw5\">-Milliseconds<\/span> <span class=\"re0\">$time<\/span><br \/>\n&nbsp; &nbsp; <span class=\"br0\">&#125;<\/span><br \/>\n&nbsp; &nbsp; <span class=\"kw1\">Write-Progress<\/span> <span class=\"kw5\">-Activity<\/span> <span class=\"st0\">&quot;Testing&quot;<\/span> <span class=\"kw5\">-Status<\/span> <span class=\"st0\">&quot;Testing&quot;<\/span> <span class=\"kw5\">-PercentComplete<\/span> <span class=\"nu0\">100<\/span> <span class=\"kw5\">-Completed<\/span><br \/>\n&nbsp; &nbsp; <span class=\"st0\">&quot;Annnd we're done.&quot;<\/span><br \/>\n<span class=\"br0\">&#125;<\/span><br \/>\n<br \/>\n<span class=\"co1\">## Kill any current jobs in the sessions and get rid of them<\/span><br \/>\nGet<span class=\"sy0\">-<\/span>Job <span class=\"sy0\">|<\/span> Stop<span class=\"sy0\">-<\/span>Job<br \/>\nGet<span class=\"sy0\">-<\/span>Job <span class=\"sy0\">|<\/span> Remove<span class=\"sy0\">-<\/span>Job<br \/>\n<br \/>\n<span class=\"co1\">## Loop control<\/span><br \/>\n<span class=\"re0\">$x<\/span> <span class=\"sy0\">=<\/span> <span class=\"nu0\">0<\/span><br \/>\n<br \/>\n<span class=\"co1\">## While we are still launching threads or wait for them to close<\/span><br \/>\n<span class=\"kw3\">While<\/span> <span class=\"br0\">&#40;<\/span><span class=\"br0\">&#40;<\/span><span class=\"re0\">$x<\/span> <span class=\"kw4\">-lt<\/span> <span class=\"nu0\">10<\/span><span class=\"br0\">&#41;<\/span> <span class=\"kw4\">-or<\/span> <span class=\"br0\">&#40;<\/span>$<span class=\"br0\">&#40;<\/span>Get<span class=\"sy0\">-<\/span>Job <span class=\"sy0\">-<\/span>State <span class=\"st0\">&quot;Running&quot;<\/span><span class=\"br0\">&#41;<\/span>.count <span class=\"kw4\">-gt<\/span> <span class=\"nu0\">0<\/span><span class=\"br0\">&#41;<\/span><span class=\"br0\">&#41;<\/span><span class=\"br0\">&#123;<\/span><br \/>\n&nbsp; &nbsp; <span class=\"co1\">## While there are less than three jobs running and less than 10 have started<\/span><br \/>\n&nbsp; &nbsp; <span class=\"kw3\">While<\/span> <span class=\"br0\">&#40;<\/span><span class=\"br0\">&#40;<\/span>$<span class=\"br0\">&#40;<\/span>Get<span class=\"sy0\">-<\/span>Job <span class=\"sy0\">-<\/span>State <span class=\"st0\">&quot;Running&quot;<\/span><span class=\"br0\">&#41;<\/span>.count <span class=\"kw4\">-lt<\/span> <span class=\"nu0\">3<\/span><span class=\"br0\">&#41;<\/span> <span class=\"kw4\">-and<\/span> <span class=\"br0\">&#40;<\/span><span class=\"re0\">$x<\/span> <span class=\"kw4\">-lt<\/span> <span class=\"nu0\">10<\/span><span class=\"br0\">&#41;<\/span><span class=\"br0\">&#41;<\/span><span class=\"br0\">&#123;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; Start<span class=\"sy0\">-<\/span>Job <span class=\"sy0\">-<\/span>ScriptBlock <span class=\"re0\">$ThreadCode<\/span> <span class=\"sy0\">|<\/span> <span class=\"kw1\">Out-Null<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; <span class=\"re0\">$x<\/span><span class=\"sy0\">++<\/span><br \/>\n&nbsp; &nbsp; <span class=\"br0\">&#125;<\/span><br \/>\n&nbsp; &nbsp; <br \/>\n&nbsp; &nbsp; <span class=\"co1\">## Main portion - Read all jobs<\/span><br \/>\n&nbsp; &nbsp; <span class=\"kw3\">ForEach<\/span> <span class=\"br0\">&#40;<\/span><span class=\"re0\">$Job<\/span> <span class=\"kw3\">in<\/span> Get<span class=\"sy0\">-<\/span>Job<span class=\"br0\">&#41;<\/span> <span class=\"br0\">&#123;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; <span class=\"co1\">## Read all children of all jobs<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; <span class=\"kw3\">ForEach<\/span> <span class=\"br0\">&#40;<\/span><span class=\"re0\">$Child<\/span> <span class=\"kw3\">in<\/span> <span class=\"re0\">$Job<\/span>.ChildJobs<span class=\"br0\">&#41;<\/span><span class=\"br0\">&#123;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class=\"co1\">## Get the latest progress object of the job<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class=\"re0\">$Progress<\/span> <span class=\"sy0\">=<\/span> <span class=\"re0\">$Child<\/span>.Progress<span class=\"br0\">&#91;<\/span><span class=\"re0\">$Child<\/span>.Progress.Count <span class=\"sy0\">-<\/span> <span class=\"nu0\">1<\/span><span class=\"br0\">&#93;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class=\"co1\">## If there is a progress object returned write progress<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class=\"kw3\">If<\/span> <span class=\"br0\">&#40;<\/span><span class=\"re0\">$Progress<\/span>.Activity <span class=\"kw4\">-ne<\/span> <span class=\"re0\">$Null<\/span><span class=\"br0\">&#41;<\/span><span class=\"br0\">&#123;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class=\"kw1\">Write-Progress<\/span> &nbsp;<span class=\"kw5\">-Activity<\/span> <span class=\"re0\">$Job<\/span>.Name <br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class=\"kw5\">-Status<\/span> <span class=\"re0\">$Progress<\/span>.StatusDescription <br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class=\"kw5\">-PercentComplete<\/span> <span class=\"re0\">$Progress<\/span>.PercentComplete <br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class=\"kw5\">-ID<\/span> <span class=\"re0\">$Job<\/span>.ID<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class=\"br0\">&#125;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class=\"co1\">## If this child is complete then stop writing progress<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class=\"kw3\">If<\/span> <span class=\"br0\">&#40;<\/span><span class=\"re0\">$Progress<\/span>.PercentComplete <span class=\"kw4\">-eq<\/span> <span class=\"nu0\">100<\/span><span class=\"br0\">&#41;<\/span><span class=\"br0\">&#123;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class=\"kw1\">Write-Progress<\/span> &nbsp;<span class=\"kw5\">-Activity<\/span> <span class=\"re0\">$Job<\/span>.Name <br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class=\"kw5\">-Status<\/span> <span class=\"re0\">$Progress<\/span>.StatusDescription <br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class=\"kw5\">-PercentComplete<\/span> <span class=\"re0\">$Progress<\/span>.PercentComplete <br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class=\"kw5\">-ID<\/span> <span class=\"re0\">$Job<\/span>.ID <br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class=\"sy0\">-<\/span>Complete<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class=\"co1\">## Clear all progress entries so we don't process it again<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class=\"re0\">$Child<\/span>.Progress.<span class=\"kw2\">Clear<\/span><span class=\"br0\">&#40;<\/span><span class=\"br0\">&#41;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class=\"br0\">&#125;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; <span class=\"br0\">&#125;<\/span><br \/>\n&nbsp; &nbsp; <span class=\"br0\">&#125;<\/span><br \/>\n&nbsp; &nbsp; <br \/>\n&nbsp; &nbsp; Get<span class=\"sy0\">-<\/span>Job <span class=\"sy0\">-<\/span>State <span class=\"st0\">&quot;Completed&quot;<\/span> <span class=\"sy0\">|<\/span> Receive<span class=\"sy0\">-<\/span>Job<br \/>\n&nbsp; &nbsp; <br \/>\n&nbsp; &nbsp; <span class=\"co1\">## Setting for loop processing speed<\/span><br \/>\n&nbsp; &nbsp; <span class=\"kw1\">Start-Sleep<\/span> <span class=\"kw5\">-Milliseconds<\/span> <span class=\"nu0\">200<\/span><br \/>\n<span class=\"br0\">&#125;<\/span><br \/>\n<br \/>\nGet<span class=\"sy0\">-<\/span>Job <span class=\"sy0\">|<\/span> Wait<span class=\"sy0\">-<\/span>Job <span class=\"sy0\">|<\/span> <span class=\"kw1\">Out-Null<\/span><br \/>\nGet<span class=\"sy0\">-<\/span>Job <span class=\"sy0\">|<\/span> Receive<span class=\"sy0\">-<\/span>Job<\/div><\/div>\n","protected":false},"excerpt":{"rendered":"<p>In this post I would like to talk about tracking the status of your various threads.  In other words, how can you see a progress of what your child script is doing?<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_mi_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[4],"tags":[],"_links":{"self":[{"href":"http:\/\/www.Get-Blog.com\/index.php?rest_route=\/wp\/v2\/posts\/132"}],"collection":[{"href":"http:\/\/www.Get-Blog.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.Get-Blog.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.Get-Blog.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.Get-Blog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=132"}],"version-history":[{"count":0,"href":"http:\/\/www.Get-Blog.com\/index.php?rest_route=\/wp\/v2\/posts\/132\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.Get-Blog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=132"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.Get-Blog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=132"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.Get-Blog.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=132"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}