PowerShell script exchange
Post Reply
sfaits
Enthusiast
Posts: 39
Liked: 9 times
Joined: Apr 07, 2017 7:08 pm
Contact:

Getting Job Schedules, Start, last run, and next run

Post by sfaits »

I am using Get-VBRJob and parsing out the ScheduleOptions to get a variety of data on the jobs but I am noticing that the NextRun, LatestRunLocal, and StartDateLocalTime all return an incorrect date but do give the correct time.
It does this for all the jobs I check.
I also get the same results with Get-VBRJobScheduleOptions.

When I log into the Database schema and check the View dbo.JobsView the XML stored in schedules field has all the correct data.

Any idea why those cmdlets would be returning bad dates?

Thanks!
Natalia Lupacheva
Veteran
Posts: 1143
Liked: 302 times
Joined: Apr 27, 2020 12:46 pm
Full Name: Natalia Lupacheva
Contact:

Re: Getting Job Schedules, Start, last run, and next run

Post by Natalia Lupacheva »

Hi William,

Could you please clarify what's exactly incorrect?
If we are talking about date format, this thread might help you to solve this issue (you can take a look at the workaround for date formatting).
If it's not about the date formatting, please give us some details.

Thanks!
sfaits
Enthusiast
Posts: 39
Liked: 9 times
Joined: Apr 07, 2017 7:08 pm
Contact:

Re: Getting Job Schedules, Start, last run, and next run

Post by sfaits »

Here is some test code I have been using plus the results returned.

======================

Code: Select all

$jobName = "backupjob1"
$temp = Get-VBRJob -name $jobName
$temp.ScheduleOptions
<...removed lines....>
StartDateTimeLocal                    : 4/2/2020 11:55:00 PM
EndDateTimeSpecified                  : False
EndDateTimeLocal                      : 4/4/2020 8:01:55 AM
<...removed lines....>
NextRun                               : 04/23/2020 23:55:00
LatestRunLocal                        : 4/22/2020 11:55:13 PM
<...removed lines....>
=======================

I would expect the NextRun to be 8/24/2020 23:55:00 as the job runs daily
and the LastRunLocal to 8/23/2020 23:55:00 since that is when it last ran.
Natalia Lupacheva
Veteran
Posts: 1143
Liked: 302 times
Joined: Apr 27, 2020 12:46 pm
Full Name: Natalia Lupacheva
Contact:

Re: Getting Job Schedules, Start, last run, and next run

Post by Natalia Lupacheva »

Hi William,

sorry for late response.
So there's not a formatting issue and the dates you get via Powershell commands don't even match the information you see in VBR, right?
In that case it's better to open a Support ticket, because it doesn't seem to be some known issue.

Thanks!
sfaits
Enthusiast
Posts: 39
Liked: 9 times
Joined: Apr 07, 2017 7:08 pm
Contact:

Re: Getting Job Schedules, Start, last run, and next run

Post by sfaits »

Thank you Natalia I will get a case opened. :)
sfaits
Enthusiast
Posts: 39
Liked: 9 times
Joined: Apr 07, 2017 7:08 pm
Contact:

Re: Getting Job Schedules, Start, last run, and next run

Post by sfaits » 2 people like this post

Got a quick response that this is a known issue and that they are working on getting a fix scheduled for v11 or possibly a hotfix, depending.
As a work around they suggest using the LatestRun data within the LatestRunLocal property of Veeam.Backup.Core.CBackupJob
Natalia Lupacheva
Veteran
Posts: 1143
Liked: 302 times
Joined: Apr 27, 2020 12:46 pm
Full Name: Natalia Lupacheva
Contact:

Re: Getting Job Schedules, Start, last run, and next run

Post by Natalia Lupacheva »

Hi William,

Thank you for the follow-up! Appreciate it.

Thanks!
ratkinsonuk
Expert
Posts: 111
Liked: 16 times
Joined: Dec 10, 2018 10:59 am
Full Name: Robert Atkinson
Contact:

Re: Getting Job Schedules, Start, last run, and next run

Post by ratkinsonuk »

Any update on a fix for this one?

Cheers, Rob.
Natalia Lupacheva
Veteran
Posts: 1143
Liked: 302 times
Joined: Apr 27, 2020 12:46 pm
Full Name: Natalia Lupacheva
Contact:

Re: Getting Job Schedules, Start, last run, and next run

Post by Natalia Lupacheva »

Hi Robert,

Does the suggested workaround work for you?
As for v11, cannot give you any ETA.

Thanks!
ratkinsonuk
Expert
Posts: 111
Liked: 16 times
Joined: Dec 10, 2018 10:59 am
Full Name: Robert Atkinson
Contact:

Re: Getting Job Schedules, Start, last run, and next run

Post by ratkinsonuk »

From what I can see, LatestRunLocal holds the last time it was run, not when it's going to be run?

PS C:\Users\Rob> $A = Get-VBRJob -name PROD_DAILY_COL_FILE_BACKUP
PS C:\Users\Rob> $A.LatestRunLocal

22 November 2020 21:00:02
jhoughes
Veeam Vanguard
Posts: 282
Liked: 113 times
Joined: Apr 20, 2017 4:19 pm
Full Name: Joe Houghes
Location: Castle Rock, CO
Contact:

Re: Getting Job Schedules, Start, last run, and next run

Post by jhoughes »

Correct, LatestRunLocal is the most recent past job run.

You need to be looking at the NextRun property.
Husband, Father, Solutions Architect, Geek | @DenverVMUG & @DenverPSUG leader | International Speaker | Veeam Vanguard | vExpert (PRO) | Cisco Champion
ratkinsonuk
Expert
Posts: 111
Liked: 16 times
Joined: Dec 10, 2018 10:59 am
Full Name: Robert Atkinson
Contact:

Re: Getting Job Schedules, Start, last run, and next run

Post by ratkinsonuk »

NextRun is the one that doesn't work though, or is there another NextRun property somewhere else?

PS C:\Windows\system32> $A = Get-VBRJob -name PROD_DAILY_COL_FILE_BACKUP
PS C:\Windows\system32> $A.ScheduleOptions

NextRun : 11/10/2020 21:00:00
jhoughes
Veeam Vanguard
Posts: 282
Liked: 113 times
Joined: Apr 20, 2017 4:19 pm
Full Name: Joe Houghes
Location: Castle Rock, CO
Contact:

Re: Getting Job Schedules, Start, last run, and next run

Post by jhoughes »

Gotcha, hadn't realized that property had a problem. Apologies on that.
Husband, Father, Solutions Architect, Geek | @DenverVMUG & @DenverPSUG leader | International Speaker | Veeam Vanguard | vExpert (PRO) | Cisco Champion
ratkinsonuk
Expert
Posts: 111
Liked: 16 times
Joined: Dec 10, 2018 10:59 am
Full Name: Robert Atkinson
Contact:

Re: Getting Job Schedules, Start, last run, and next run

Post by ratkinsonuk » 1 person likes this post

I was struggling to implement the workaround for this issue, so here are the 2 options available for anyone else tackling the same problem.

Code: Select all

PS > $a = Get-VBRJob -name "PROD_DAILY_FILE_BACKUP"
PS > $a.GetScheduleOptions() | select NextRun, LatestRunLocal

NextRun             LatestRunLocal
-------             --------------
25/11/2020 20:00:00 24/11/2020 20:00:25


PS > Get-VBRJobScheduleOptions -job $a | select NextRun, LatestRunLocal

NextRun             LatestRunLocal
-------             --------------
25/11/2020 20:00:00 24/11/2020 20:00:25
oleg.feoktistov
Veeam Software
Posts: 2010
Liked: 670 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: Getting Job Schedules, Start, last run, and next run

Post by oleg.feoktistov » 1 person likes this post

Hi Robert,

Actually, the issue was fixed in v10 a with Get-VBRJobScheduleOptions, which is a synonym for GetScheduleOptions() method. So, as I see above, you succeeded in retrieving these properties.

Best regards,
Oleg
ratkinsonuk
Expert
Posts: 111
Liked: 16 times
Joined: Dec 10, 2018 10:59 am
Full Name: Robert Atkinson
Contact:

Re: Getting Job Schedules, Start, last run, and next run

Post by ratkinsonuk »

Thanks for the additional info Oleg. I wasn't aware Get-VBRJobScheduleOptions is a new (v10) cmdlet.

Rob.
oleg.feoktistov
Veeam Software
Posts: 2010
Liked: 670 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: Getting Job Schedules, Start, last run, and next run

Post by oleg.feoktistov »

I wasn't aware Get-VBRJobScheduleOptions is a new (v10) cmdlet.
It is pretty ancient, actually. We just fixed the issue with incorrect values in v10a in scope of this cmdlet. Thanks!
Post Reply

Who is online

Users browsing this forum: No registered users and 8 guests