PowerShell script exchange
Post Reply
shaun2011
Influencer
Posts: 19
Liked: 1 time
Joined: Nov 12, 2011 11:43 am
Contact:

Get job start time using Powershell

Post by shaun2011 »

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.
Sethbartlett
Veteran
Posts: 282
Liked: 26 times
Joined: Nov 10, 2010 6:51 pm
Full Name: Seth Bartlett
Contact:

Re: Get job start time using Powershell

Post by Sethbartlett » 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.
shaun2011
Influencer
Posts: 19
Liked: 1 time
Joined: Nov 12, 2011 11:43 am
Contact:

Re: Get job start time using Powershell

Post by shaun2011 »

thanks seth .. all good.

i've noticed last state is $job.getlaststate(). where can i find all the variables for a job?
Sethbartlett
Veteran
Posts: 282
Liked: 26 times
Joined: Nov 10, 2010 6:51 pm
Full Name: Seth Bartlett
Contact:

Re: Get job start time using Powershell

Post by Sethbartlett » 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.
shaun2011
Influencer
Posts: 19
Liked: 1 time
Joined: Nov 12, 2011 11:43 am
Contact:

Re: Get job start time using Powershell

Post by shaun2011 »

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 ...
Andreas Neufert
VP, Product Management
Posts: 7081
Liked: 1511 times
Joined: May 04, 2011 8:36 am
Full Name: Andreas Neufert
Location: Germany
Contact:

Re: Get job start time using Powershell

Post by Andreas Neufert » 1 person likes this post

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

Re: Get job start time using Powershell

Post by shaun2011 »

thanks, jobcheduleOptions sorted.

where can i find variables for job statistics? particularly % completed during run time?
Andreas Neufert
VP, Product Management
Posts: 7081
Liked: 1511 times
Joined: May 04, 2011 8:36 am
Full Name: Andreas Neufert
Location: Germany
Contact:

Re: Get job start time using Powershell

Post by Andreas Neufert »

In this script you can find an example,
http://forums.veeam.com/viewtopic.php?f ... ing#p59844

If you delete –runasync from the run Job command, you will see a powershell % compleation bar.
shaun2011
Influencer
Posts: 19
Liked: 1 time
Joined: Nov 12, 2011 11:43 am
Contact:

Re: Get job start time using Powershell

Post by shaun2011 »

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.
Post Reply

Who is online

Users browsing this forum: No registered users and 10 guests