two background jobs colision

Ask your Windows PowerShell-related questions, including questions on cmdlet development!
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.
User avatar
Posts: 16
Joined: Wed Apr 22, 2015 4:57 am

Re: two background jobs colision

Post by noescape » Wed Jan 13, 2016 6:09 am

jvierra wrote:
noescape wrote:Thanks for useful information, it makes sense. I figured it out myself but I'm glad it was the right place to stop the timer.
Here is how to run a continuous background ping against multiple computers. It will run until you stop the job. You can use a timer to poll the job and display/update the status of the computers. Other tasks can just test the status. I use read only checkboxes to display status and se the color. If checked the computer is online and responding.

Code: Select all

workflow pingall {
foreach -parallel($c in $computers) {
Test-Connection $c -Count 1
sleep 2
pingall 'omega', 'w8test', 'alpha'
pingall 'omega', 'w8test', 'alpha' -asjob -JobName PingAll

Perfect, I was experimenting with parallel workflow before but couldn't get it to update my form controls correctly. In my form I also use a datagridview with readonly checkbox column to display status of queried stations so that should be easy to set up.
Thanks a lot for this piece of code.