Get job start time using Powershell

PowerShell script exchange

Get job start time using Powershell

Veeam Logoby shaun2011 » Mon Oct 01, 2012 12:11 pm

hello all,

basically want to get the start time of a running job as a variable, i've started off with something like below and now stuck,

$job = Get-VBRJob -Name "Some Job" | ? {$_.GetLastState() -eq "Working"}

so i could compare periodically with current time and if gt than x hrs, send an alert. i believe veeam alerts only get generated after reaching a state not while running ...

any advice?

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

Re: Get job start time using Powershell

Veeam Logoby Sethbartlett » Mon Oct 01, 2012 2:45 pm 1 person likes this post

Code: Select all
$Job = Get-VBRJob -name "Name of Job"
$Job.ScheduleOptions.StartDateTime
Skype: Sethbartlett88 - Make sure to label who you are and why you want to add me ;)
Twitter: @sethbartlett
If my post was helpful, please like it. Sometimes twitter is quicker to hit me up if you need me.
Sethbartlett
Expert
 
Posts: 282
Liked: 25 times
Joined: Wed Nov 10, 2010 6:51 pm
Full Name: Seth Bartlett

Re: Get job start time using Powershell

Veeam Logoby shaun2011 » Tue Oct 02, 2012 12:11 pm

thanks seth .. all good.

i've noticed last state is $job.getlaststate(). where can i find all the variables for a job?
shaun2011
Influencer
 
Posts: 19
Liked: 1 time
Joined: Sat Nov 12, 2011 11:43 am

Re: Get job start time using Powershell

Veeam Logoby Sethbartlett » Tue Oct 02, 2012 6:17 pm 1 person likes this post

Code: Select all
$job | Gm


GM is short for Get-Member cmdlet which shows you all the methods/properties on an object in powershell.
Skype: Sethbartlett88 - Make sure to label who you are and why you want to add me ;)
Twitter: @sethbartlett
If my post was helpful, please like it. Sometimes twitter is quicker to hit me up if you need me.
Sethbartlett
Expert
 
Posts: 282
Liked: 25 times
Joined: Wed Nov 10, 2010 6:51 pm
Full Name: Seth Bartlett

Re: Get job start time using Powershell

Veeam Logoby shaun2011 » Thu Oct 04, 2012 8:48 am

thanks seth, can you explain a bit how to view options under each property, i tried,

$job = Get-VBRJob -name PER3SVR4-REPL
write-host $job.ScheduleOptions

but this does not list Job.ScheduleOptions.StartDateTime variable anywhere?

also wanted to know the variable for % completed when a job is active as well ..

just starting with poweershelll for veeam ...
shaun2011
Influencer
 
Posts: 19
Liked: 1 time
Joined: Sat Nov 12, 2011 11:43 am

Re: Get job start time using Powershell

Veeam Logoby Andreas Neufert » Thu Oct 04, 2012 12:49 pm 1 person likes this post

Andreas Neufert
Veeam Software
 
Posts: 2201
Liked: 360 times
Joined: Wed May 04, 2011 8:36 am
Location: Germany
Full Name: @AndyandtheVMs Veeam PM

Re: Get job start time using Powershell

Veeam Logoby shaun2011 » Thu Oct 04, 2012 2:18 pm

thanks, jobcheduleOptions sorted.

where can i find variables for job statistics? particularly % completed during run time?
shaun2011
Influencer
 
Posts: 19
Liked: 1 time
Joined: Sat Nov 12, 2011 11:43 am

Re: Get job start time using Powershell

Veeam Logoby Andreas Neufert » Thu Oct 04, 2012 2:43 pm

In this script you can find an example,
viewtopic.php?f=26&t=13086&p=59844&hilit=andys+scripting#p59844

If you delete –runasync from the run Job command, you will see a powershell % compleation bar.
Andreas Neufert
Veeam Software
 
Posts: 2201
Liked: 360 times
Joined: Wed May 04, 2011 8:36 am
Location: Germany
Full Name: @AndyandtheVMs Veeam PM

Re: Get job start time using Powershell

Veeam Logoby shaun2011 » Sun Oct 14, 2012 1:09 pm

thanks andreas.. i was more after a variable or a formula to get the % complete value of a running job which started by GUI scheduling (not initiated via a script). i am writing a script to email an alert when a job goes over x hrs.

is there a way to get the value using a calculation?

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


Return to PowerShell



Who is online

Users browsing this forum: No registered users and 3 guests