PowerShell script exchange
Post Reply
marius roma
Veteran
Posts: 459
Liked: 5 times
Joined: Feb 01, 2012 12:04 pm
Full Name: Mario
Contact:

Getting information about jobs completed in the past

Post by marius roma »

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
veremin
Product Manager
Posts: 20271
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Getting information about jobs completed in the past

Post by veremin »

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

Who is online

Users browsing this forum: No registered users and 18 guests