I want to measure how long time the job took to finish?
how do i do that when i use the Add-Jobtracker for my functions?
Add-JobTracker - how to measure time
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.
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.
Re: Add-JobTracker - how to measure time
Get the time before you start the job: $starttime = [datetime]::Now
Get the time when job ends: $endtime =[datetime]::Now
Now the elapsed time: $elapsedtime = $endtime - $starttime
This will help you get started with PowerShell and using math with objects.
https://www.sapien.com/books_training/W ... werShell-4
Get the time when job ends: $endtime =[datetime]::Now
Now the elapsed time: $elapsedtime = $endtime - $starttime
This will help you get started with PowerShell and using math with objects.
https://www.sapien.com/books_training/W ... werShell-4
Re: Add-JobTracker - how to measure time
that was also my first attempt but when i got multiple Jobs running I need to know when the last one stopped to get the overall time.
So at each job end have a datetime appended to a array and from that array take the oldest date but when do i know that every think is done?
So at each job end have a datetime appended to a array and from that array take the oldest date but when do i know that every think is done?
Re: Add-JobTracker - how to measure time
I recommend starting with the free book I linked. It will teach you the basics of how to test various conditions in a script.
You will need to check the jobs array. When it is empty then all jobs are done.
Note that each job object also has the runtime and job status included in the job object.
https://learn.microsoft.com/en-us/dotne ... lsdk-7.2.0
The job object also contains the job start and end times.
You will need to check the jobs array. When it is empty then all jobs are done.
Note that each job object also has the runtime and job status included in the job object.
https://learn.microsoft.com/en-us/dotne ... lsdk-7.2.0
The job object also contains the job start and end times.