Jobs in sequential order

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 5 years and 7 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
apowershelluser
Posts: 194
Last visit: Fri Mar 22, 2024 4:38 am
Answers: 2

Jobs in sequential order

Post by apowershelluser »

I've seen an example on this site before I cannot seem to googlefu it

Essentially, I need Job 1 to complete before I can start Job 2 as a need the result of Job 1, for Job2
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Jobs in sequential order

Post by jvierra »

Sorry but your question is far to vague to guess at an answer.
User avatar
apowershelluser
Posts: 194
Last visit: Fri Mar 22, 2024 4:38 am
Answers: 2

Re: Jobs in sequential order

Post by apowershelluser »

Hello, sorry for that.

I have a button-startjob
There are two jobs within the click event
Job 1 gathers the username
Job 2 gathers their networked printers

I would usually not use a job, but I'm developing an application for VPN users and the latency some of them experience causes the application to freeze.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Jobs in sequential order

Post by jvierra »

That does not explain what you are asking or what the problem is.
I do not see why you need a jib to get a username. Use $env:USERNAME. It is always available.
User avatar
apowershelluser
Posts: 194
Last visit: Fri Mar 22, 2024 4:38 am
Answers: 2

Re: Jobs in sequential order

Post by apowershelluser »

we're hiring wfh tech support people, whose customers will always be in the office. To prevent the application from freezing, we're thinking running the jobs in order, instead of all at the same time.
So I just the button click to do:

Job1, once that is complete do Job 2
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Jobs in sequential order

Post by jvierra »

Start job 2 when job 1 completes. Why is that an issue?
User avatar
apowershelluser
Posts: 194
Last visit: Fri Mar 22, 2024 4:38 am
Answers: 2

Re: Jobs in sequential order

Post by apowershelluser »

I cannot figure out how to do it. I've seen an example on this board but I cannot find it.
User avatar
apowershelluser
Posts: 194
Last visit: Fri Mar 22, 2024 4:38 am
Answers: 2

Re: Jobs in sequential order

Post by apowershelluser »

I just changed the jobtracker tick event
  1. $timerJobTracker_Tick={
  2.     Update-JobTracker
  3. If ($JobTrackerList.Count -eq 0)
  4.     {
  5.         Add-JobTracker -Name 'JobNameGetPrinters' .........
  6.     }}
User avatar
apowershelluser
Posts: 194
Last visit: Fri Mar 22, 2024 4:38 am
Answers: 2

Re: Jobs in sequential order

Post by apowershelluser »

That did work until I got in the office and I noticed that it just keeps running the job lol even if I put stop-job $job at the last line
User avatar
apowershelluser
Posts: 194
Last visit: Fri Mar 22, 2024 4:38 am
Answers: 2

Re: Jobs in sequential order

Post by apowershelluser »

I just added this to the end of the job that gets the users name... everything works perfectly
This topic is 5 years and 7 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