Gather a (or some) backup sessions (in this case, successful backup sessions within the last 2 hours)
Output the session info
Notice Total (GB) equals 140 (as it should/confirmed)
Then gather tasksessions for that session
Output same exact session info
Notice Total (GB) is now 240 (double what it should be)
If you change one line and omit the Get-VBRTaskSession command everything outputs as expected (with $taskList now holding sessions and not tasksessions...).
$task = $session | Get-VBRTaskSession
to
$task = $session# | Get-VBRTaskSession
Is there any reason why running Get-VBRTaskSession would change the value?
Note - there is a handful of values that will double under session.progress not just this one
Code: Select all
$HourstoCheck = 2
# Gather all sessions
$allSessions = Get-VBRBackupSession
# Gather just successful backup sessions within $HourstoCheck
$successSessions = $allSessions | ?{$_.CreationTime -ge (Get-Date).AddHours(-$HourstoCheck) -and $_.JobType -eq "Backup" -and $_.Result -eq "Success"}
# Output Session Info
$successSessions | Select @{Name="Job Name"; Expression = {$_.Name}},
@{Name="Start Time"; Expression = {$_.CreationTime}},
@{Name="Stop Time"; Expression = {$_.EndTime}},
@{Name="Total (GB)"; Expression = {[Math]::Round($_.Progress.ProcessedSize/1GB,2)}},
Result, ID
# Gather all Backup Tasks from Sessions created within time frame
$taskList = @()
Foreach ($session in $successSessions) {
$task = $session | Get-VBRTaskSession
$taskList += $task
}
# Output Session Info
$successSessions | Select @{Name="Job Name"; Expression = {$_.Name}},
@{Name="Start Time"; Expression = {$_.CreationTime}},
@{Name="Stop Time"; Expression = {$_.EndTime}},
@{Name="Total (GB)"; Expression = {[Math]::Round($_.Progress.ProcessedSize/1GB,2)}},
Result, ID
Code: Select all
Job Name : Temp Backup Job (Reverse Incremental)
Start Time : 10/15/2016 2:31:08 AM
Stop Time : 10/15/2016 2:36:01 AM
Total (GB) : 140
Result : Success
Id : 22d09531-431c-43f1-a916-2cefa0354a6a
Job Name : Temp Backup Job (Reverse Incremental)
Start Time : 10/15/2016 2:31:08 AM
Stop Time : 10/15/2016 2:36:01 AM
Total (GB) : 280
Result : Success
Id : 22d09531-431c-43f1-a916-2cefa0354a6a