Jobs in sequential order

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.
Locked
User avatar
JohnTitor
Posts: 153
Joined: Fri Nov 17, 2017 8:49 pm

Jobs in sequential order

Post by JohnTitor » Wed Aug 22, 2018 9:23 pm

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

User avatar
jvierra
Posts: 13718
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: Jobs in sequential order

Post by jvierra » Wed Aug 22, 2018 9:26 pm

Sorry but your question is far to vague to guess at an answer.

User avatar
JohnTitor
Posts: 153
Joined: Fri Nov 17, 2017 8:49 pm

Re: Jobs in sequential order

Post by JohnTitor » Wed Aug 22, 2018 9:44 pm

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.

User avatar
jvierra
Posts: 13718
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: Jobs in sequential order

Post by jvierra » Wed Aug 22, 2018 9:48 pm

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
JohnTitor
Posts: 153
Joined: Fri Nov 17, 2017 8:49 pm

Re: Jobs in sequential order

Post by JohnTitor » Wed Aug 22, 2018 9:57 pm

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

User avatar
jvierra
Posts: 13718
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: Jobs in sequential order

Post by jvierra » Wed Aug 22, 2018 10:03 pm

Start job 2 when job 1 completes. Why is that an issue?

User avatar
JohnTitor
Posts: 153
Joined: Fri Nov 17, 2017 8:49 pm

Re: Jobs in sequential order

Post by JohnTitor » Wed Aug 22, 2018 10:07 pm

I cannot figure out how to do it. I've seen an example on this board but I cannot find it.

User avatar
JohnTitor
Posts: 153
Joined: Fri Nov 17, 2017 8:49 pm

Re: Jobs in sequential order

Post by JohnTitor » Wed Aug 22, 2018 10:37 pm

I just changed the jobtracker tick event

Code: Select all

$timerJobTracker_Tick={
Update-JobTracker
If ($JobTrackerList.Count -eq 0)
{
Add-JobTracker -Name 'JobNameGetPrinters' .........
}}

User avatar
JohnTitor
Posts: 153
Joined: Fri Nov 17, 2017 8:49 pm

Re: Jobs in sequential order

Post by JohnTitor » Thu Aug 23, 2018 7:29 am

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
JohnTitor
Posts: 153
Joined: Fri Nov 17, 2017 8:49 pm

Re: Jobs in sequential order

Post by JohnTitor » Thu Aug 23, 2018 8:00 am

I just added this to the end of the job that gets the users name... everything works perfectly

Locked