Getting information about jobs completed in the past

PowerShell script exchange

Getting information about jobs completed in the past

Veeam Logoby marius roma » Wed Jul 05, 2017 1:29 pm

I need to extract as many information as possible about backup jobs completed in the past.
I create the following script (copying from forums and blogs) and it looks to work:
Code: Select all
Asnp VeeamPSSnapin
foreach ($Job in (Get-VBRJob | where {$_.JobType -eq "Backup"}))
    {
    foreach ($Session in (Get-VBRBackupSession | Where {$_.Jobname -eq $Job.name}) | Sort creationtime -Descending)
        {
        foreach ($TaskSession in $Session.GetTaskSessions())
            {
                $task_name = $TaskSession.name
                $session_name_job = $Job.Name
                $task_start = get-date $taskSession.Progress.StartTime -format g
                $task_end = get-date $taskSession.Progress.StopTime -format g
                $line = ""
                $line = $task_name + ";" + $session_name_job + ";" + $task_start + ";" + $task_end
                $line >> "C:\temp\mylist.txt"
            }
        }
    }     

However, if I select a given job from the Veeam B&R console and select to display the report I see many more data than in the result of my script.
Just to give an example, the earliest execution of a job reported by the result of my script is October 2016 while the data shown in the record start from July 2016.
How can I tell my scruipt to display all the available information?
Regards
marius
marius roma
Expert
 
Posts: 339
Liked: 3 times
Joined: Wed Feb 01, 2012 12:04 pm
Full Name: Mario

Re: Getting information about jobs completed in the past

Veeam Logoby v.Eremin » Wed Jul 05, 2017 3:28 pm

I think it must have to do with the fact that you're trying to catch session based on session name, not on job Id.

Retry sessions, full backup sessions, session initiated manually - all have different names not exactly matching job one. For instance, full backup session for job name "Test Job" will be named "Test Job (Full)", etc.

Try to run the following script and see whether it returns the same session as GUI does:

Code: Select all
$Job = Get-VBRJob -Name "Name of your Job"
$OldestSession  = Get-VBRBackupSession | Where {$_.JobId -eq $Job.Id.Guid} | sort creationtimeutc -Descending | select -Last 1| select name, creationtimeutc
$OldestSession


Thanks.
v.Eremin
Veeam Software
 
Posts: 13864
Liked: 1037 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 1 guest