PowerShell script exchange
Post Reply
Pierpa
Influencer
Posts: 21
Liked: 1 time
Joined: Oct 09, 2019 7:37 am
Contact:

Job report in powershell for a day-by-day statistics.

Post by Pierpa »

Hi everybody,
I need to write a script in order to have .csv formatted output related to daily backup job statistics, I mean:
- Success
-warning
- errors
- Job name
- Start time
- Duration
- Backup size

I was able to write a script to receive an output like

VEEAM_BCK_VER_PROD_DDBOOST_DD6300;03/01/2023 22:00:19;0;Success
VEEAM_BCK_VER_PROD_DDBOOST_DD6300;03/02/2023 22:00:07;57;Success
VEEAM_BCK_VER_PROD_DDBOOST_DD6300;03/03/2023 22:00:16;59;Success
VEEAM_BCK_VER_PROD_DDBOOST_DD6300;03/04/2023 22:00:02;21;Success
VEEAM_BCK_VER_PROD_DDBOOST_DD6300;03/05/2023 22:00:12;59;Success
VEEAM_BCK_VER_PROD_DDBOOST_DD6300;03/06/2023 22:00:20;59;Success
VEEAM_BCK_VER_PROD_DDBOOST_DD6300;03/07/2023 22:00:05;1;Success
VEEAM_BCK_VER_PROD_DDBOOST_DD6300;03/08/2023 22:00:12;58;Success
VEEAM_BCK_VER_PROD_DDBOOST_DD6300;03/09/2023 22:00:19;59;Success
VEEAM_BCK_VER_PROD_DDBOOST_DD6300;03/10/2023 22:00:05;57;Success
VEEAM_BCK_VER_PROD_DDBOOST_DD6300;03/11/2023 22:00:10;26;Success

The script is like this

Code: Select all

###########################################################
$jobs = Get-VBRJob
foreach ($job in $jobs) {
$BckJ = Get-VBRBackupSession | Where {$_.jobId -eq $job.Id.Guid} | Sort EndTimeUTC -Descending

#$BckJ | sort Jobname| Format-Table -Property JobName,CreationTime,EndTime,Result

#$BckJ | sort JobName | %{
$BckJ | sort CreationTime | %{

$NameJob = $_.JobName
$StartDate = $_.CreationTime
$EndDate = $_.EndTime
$Res = $_.Result
#$Schedule = $_.SheduleEnabledTime
#
#Duration
#
$Duration = (New-TimeSpan -Start $StartDate -End $EndDate).Minutes

echo $NameJob";"$StartDate";"$Duration";"$Res
}
}
###########################################################
It seems to be ok, but I don't know how to find and show Success, warning, errors counters and expecially "Backup Size"
This is a very important value because it is what I send to the backup repository.

I've not found in Get-VBRBackupSession something related to the counters and also to "Backup size"

Could you please give my suggestion about howto find and collect these values?
I'm not a usual powershell programmer and I don't know well powershell+veeam ...

As usual, have my best regards
Pierpa
Mildur
Product Manager
Posts: 8735
Liked: 2296 times
Joined: May 13, 2017 4:51 pm
Full Name: Fabian K.
Location: Switzerland
Contact:

Re: Job report in powershell for a day-by-day statistics.

Post by Mildur »

Hi Pierpa

You can get some information from $_.sessioninfo.Progress

Code: Select all

$BckJ = Get-VBRBackupSession | Where {$_.jobId -eq $job.Id.Guid} | Sort EndTimeUTC -Descending
$BckJ[0].sessioninfo.Progress.TransferedSize      #  Transferred size (Backup size)
$BckJ[0].SessionInfo.Progress.Duration            #  Duration of the backup
Best,
Fabian
Product Management Analyst @ Veeam Software
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 16 guests