two background jobs colision

Ask your 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.
This topic is 8 years and 2 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
noescape
Posts: 16
Last visit: Tue Jan 04, 2022 2:17 am

Re: two background jobs colision

Post by noescape »

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.
  1. workflow pingall  {
  2.     param([string[]]$computers)
  3.     while(1){
  4.         foreach -parallel($c in $computers) {
  5.             Test-Connection $c -Count 1
  6.             sleep 2
  7.         }
  8.     }
  9. }
  10. pingall 'omega', 'w8test', 'alpha'
  11. 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.

Regards,

Thomas
This topic is 8 years and 2 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked