Get running job start time

PowerShell script exchange

Get running job start time

Veeam Logoby shaun2011 » Sat Aug 03, 2013 12:23 pm

hi,
what is the variable / commands to get start time of a running/active backup/replica job?

below commands did not work,
Get-VBRJob
job.getlaststate -ne "stopped"
Job.ScheduleOptions.StartDateTime

thanks.
shaun2011
Influencer
 
Posts: 19
Liked: 1 time
Joined: Sat Nov 12, 2011 11:43 am

Re: Get running job start time

Veeam Logoby v.Eremin » Mon Aug 05, 2013 8:43 am 1 person likes this post

The following one-liner should meet your expectations:

Code: Select all
asnp VeeamPSSnapin
Get-VBRJob | ?{$_.GetLastState() -eq "Running"} | Select name, {$_.ScheduleOptions.NextRun} 


Hope this helps.
Thanks.
v.Eremin
Veeam Software
 
Posts: 13291
Liked: 973 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Get running job start time

Veeam Logoby shaun2011 » Mon Aug 05, 2013 10:32 am

nope, i ran this command while the job is running and it displays the next scheduled run time of the job.

PS C:\> Get-VBRJob | ?{$_.GetLastState() -ne "stopped"} | Select name, {$_.ScheduleOptions.NextRun}
Name $_.ScheduleOptions.NextRun
---- --------------------------
REP-SERVER 08/06/2013 08:02:00

what i am trying is to get the start time of a active job (while the job is running and not in stopped state). more like current backup session start time?

thanks.
shaun2011
Influencer
 
Posts: 19
Liked: 1 time
Joined: Sat Nov 12, 2011 11:43 am

Re: Get running job start time

Veeam Logoby v.Eremin » Mon Aug 05, 2013 11:37 am 1 person likes this post

You mean the time when a given job has been started?

Code: Select all
asnp VeeamPSSnapin
Get-VBRJob | ?{$_.GetLastState() –eq "Running"} | Select name, {$_.FindLastSession().creationtime} 


Thanks.
v.Eremin
Veeam Software
 
Posts: 13291
Liked: 973 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Get running job start time

Veeam Logoby shaun2011 » Mon Aug 05, 2013 12:58 pm

yes, thanks Vladimir!
on the right track now, aim is to check on jobs that runs for longer than usual ...
shaun2011
Influencer
 
Posts: 19
Liked: 1 time
Joined: Sat Nov 12, 2011 11:43 am

Re: Get running job start time

Veeam Logoby v.Eremin » Mon Aug 05, 2013 1:17 pm 1 person likes this post

aim is to check on jobs that runs for longer than usual

Ok. Then, it might be worth using the following examples.

This one will output all active jobs that have been running more than 2 hours (this is modifiable parameter; just replace 2 with whatever number you’re willing to):

Code: Select all
asnp VeeamPSSnapin
Get-VBRJob | ?{($_.GetLastState() -eq "Running") -and (((Get-Date) - $_.FindLastSession().CreationTime).TotalHours -gt '2')} | Select name, {$_.FindLastSession().creationtime}


This one will stop all the active jobs that have been running more than 2 hours (this is modifiable parameter; just replace 2 with whatever number you’re willing to):

Code: Select all
asnp VeeamPSSnapin
Get-VBRJob | ?{($_.GetLastState() -eq "Running") -and (((Get-Date) - $_.FindLastSession().CreationTime).TotalHours -gt '2')} | Stop-VBRJob


Thanks.
v.Eremin
Veeam Software
 
Posts: 13291
Liked: 973 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Get running job start time

Veeam Logoby v.Eremin » Mon Aug 05, 2013 1:21 pm 4 people like this post

Additionally, have you ever considered implementing Veeam ONE as the solution for tracking your Virtual, as well as Backup, infrastructure. Among others interesting features, there is a predefined alarm that tracks job duration.

Thanks.
v.Eremin
Veeam Software
 
Posts: 13291
Liked: 973 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Get running job start time

Veeam Logoby shaun2011 » Tue Aug 06, 2013 10:49 am

i did not know VeeamOne can track job duration.
thanks for your help ...
shaun2011
Influencer
 
Posts: 19
Liked: 1 time
Joined: Sat Nov 12, 2011 11:43 am

Re: Get running job start time

Veeam Logoby v.Eremin » Tue Aug 06, 2013 10:55 am 1 person likes this post

You’re welcome. If any additional questions arise, don’t hesitate to let me know. Thanks.
v.Eremin
Veeam Software
 
Posts: 13291
Liked: 973 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin


Return to PowerShell



Who is online

Users browsing this forum: No registered users and 9 guests