PowerShell script exchange
Post Reply
ericstottelaar
Lurker
Posts: 2
Liked: never
Joined: Feb 20, 2026 12:46 pm
Full Name: Eric Stottelaar
Location: The Netherlands
Contact:

Powershell how to calculate job duration

Post by ericstottelaar »

[Moderator: Edited Subject to better reflect the question]

Hello,
"I might have posted this in the wrong category, so apologies for that—I’m new to this forum. My question is: how can I use PowerShell to get the duration of a replication job, excluding the preparation time?"

Someone an idea how to do this ? i searched for the right powershell command but i cannot get it.

$Session.progress.duration gives the time including the preperation time.

Regards

Eric Stottelaar
david.domask
Product Manager
Posts: 3527
Liked: 849 times
Joined: Jun 28, 2016 12:12 pm
Contact:

Re: Powershell how to calculate job duration

Post by david.domask »

Hi Eric, welcome to the forums.

Can you clarify a bit more what you mean with "excluding the preparation time"?

Getting the duration is as simple as use normal DateTime math in PowerShell:

Code: Select all

PS /root> ($sess.Progress.StopTimeUtc - $sess.Progress.StartTimeUtc)

Days              : 0
Hours             : 0
Minutes           : 2
Seconds           : 1
Milliseconds      : 198
Ticks             : 1211981750
TotalDays         : 0.00140275665509259
TotalHours        : 0.0336661597222222
TotalMinutes      : 2.01996958333333
TotalSeconds      : 121.198175
TotalMilliseconds : 121198.175
The result will be a native PowerShell TimeSpan object, and you can format that result as you see fit for your reporting.
David Domask | Product Management: Principal Analyst
ericstottelaar
Lurker
Posts: 2
Liked: never
Joined: Feb 20, 2026 12:46 pm
Full Name: Eric Stottelaar
Location: The Netherlands
Contact:

Re: Powershell how to calculate job duration

Post by ericstottelaar »

Yes what i will see the duration time whithout the time that the job had wait for resources and snapshot creation. Because when i looked at a job that has been finished i see 2 duration times 1 of 2 hours and 30 minutes and 1 duration time of 30 minutes and when i looked further i saw that the job got the resources assigned two after it started so it took 2 hours for it got the resources assigned
david.domask
Product Manager
Posts: 3527
Liked: 849 times
Joined: Jun 28, 2016 12:12 pm
Contact:

Re: Powershell how to calculate job duration

Post by david.domask »

Got it, so you want to be able to do maths specifically on each event that happens during the backup session.

Unfortunately we will need to resort to unsupported methods for this. Please see the post I linked to see how to fetch the information oyu see in the Job Statistics window for each processed machine, and from that you can use normal PowerShell date math to get your final result.
David Domask | Product Management: Principal Analyst
Post Reply

Who is online

Users browsing this forum: No registered users and 13 guests