PowerShell script exchange
Post Reply
ericstottelaar
Lurker
Posts: 1
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: 3507
Liked: 846 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
Post Reply

Who is online

Users browsing this forum: No registered users and 6 guests