Hi Oleg,
Thank you for helping me!
It also seems to give me the information... but a lot more than expected. I try to explain.
The specific Job is only a few weeks old and had two backup sessions.
Running:
$jobs.Count also returns only 1 item.
So the following foreach is only fetching information for this job. Where $job is the one job which is in $jobs.
But when fetching the sessions, it does return
all the sessions. Even sessions far before the Job was created. For some reason the Where-statement does not work on the command.
Code: Select all
$sessions = Get-VBRComputerBackupJobSession | where {$_.JobId -eq $job.Id}
When running the same expression in on the variable. It is working (?)
Code: Select all
$sessions | where {$_.JobId -eq $job.Id}
I manipulated the script a bit so only the tasks for the two sessions are used:
Code: Select all
$jobs = Get-VBRComputerBackupJob
$taskSessions = @()
foreach ($job in $jobs) {
$sessions = Get-VBRComputerBackupJobSession
$sessions2 = $sessions | where {$_.JobId -eq $job.Id}
foreach ($session in $sessions2) {
$tasks = Get-VBRTaskSession -Session $session
$taskSessions += $tasks
}
}
$taskSessions | select Name, Status, @{n='StartTime';e={$_.Info.Progress.StartTimeUtc}}, `
@{n='EndTime';e={$_.Info.Progress.StopTimeUtc}}, @{n='Size';e={$_.Info.Progress.TotalSize}}, `
@{n='Read';e={$_.Info.Progress.ReadSize}}, `
@{n='Transferred';e={$_.Info.Progress.TransferedSize}}, @{n='Duration';e={$_.Info.Progress.Duration.ToString()}}
But no tasks are found.
The tasks are found when using all the (1440) sessions. But a lot more information is shown. I only want to see the information of this specific job and those sessions.
I do not understand.