Need you help with this script :
I am gathering my backups to process details.
Unfortunately, it does not list me Agent backup infos ...
Where am I wrong ?
Code: Select all
# Getting Restore points
$VBRRestorePoint = Get-VBRRestorePoint | where {((Get-Date) - ($_.CreationTime)).totaldays -le "2"} ;
### (at this stage, I retrieve agent backup restore points)
# Getting Backup Jobs
$VBRJOBS = [Veeam.Backup.Core.CBackupJob]::GetAll()
foreach ($VBRJOB in $VBRJOBS) {
$AllJobSessions = @()
#Retrieving session for given backup job
$JobSessions = [Veeam.Backup.Core.CBackupSession]::GetByJob($VBRJOB.Id)
if ([bool]$JobSessions){
foreach ($CurrentSession in $JobSessions) {
if (((Get-Date) - ($CurrentSession.creationtime)).totaldays -le "2") {
$null=$AllJobSessions.Add($CurrentSession.id)
}
}
}
### (at this stage, I got Session Ids of all of my backups, vmware based or agent based)
$UniqueJobSessions = $AllJobSessions | Select-Object -Unique
foreach ($CurrentSessionID in $UniqueJobSessions) {
# Getting tasks in given backup session
$TaskSessions = Get-VBRTaskSession ($VBRSession)
## Problems start here for agent backups ...
#Processing task session in task sessions
foreach ($TaskSession in $TaskSessions) {
$TSNAME = $TaskSession.name ;
$TSPLATFORM = $TaskSession.Info.ObjectPlatform;
$TSSTATUS = $TaskSession.Status;
$TSPROGRESS = $TaskSession.progress;
$TSCT = $TSPROGRESS.starttimelocal.tostring("$NEWDATEFORMAT");
$TSET = $TSPROGRESS.stoptimelocal.tostring("$NEWDATEFORMAT");
$TSDUR = $TSPROGRESS.stoptimelocal - $TSPROGRESS.starttimelocal ; if ($TSDUR -lt 0) {$TSDUR="N-A";$TSET="N-A"} ;
$TSSPEED = $TSPROGRESS.AVGSPEED;
$TSTRANSFERED = $TSPROGRESS.TransferedSize;
$TSREADSIZE = $TSPROGRESS.ReadSize;
$TSTOTALGB = $TSPROGRESS.ProcessedSize;
$TSTOTALUSEDGB = $TSPROGRESS.ProcessedUsedSize;
(...)
}
}
}
Any Idea what's wrong ?
Thanks
TH