Below you can find the sample of the script, which reads information about done backups from VBR server and writes it into custom attributes of each backed up VM in vcsa (considered that custom attributes are named as “05-last-backup”, “06-vbr-restore-points”, “07-vbr-job-options”; vcsa is named as “vcsa.itforce.local”; VBR is named as “veeambr.itforce.local”)
To pre-create custom attributes for each VM in your vcsa:
connect-viserver vcsa.itforce.local New-CustomAttribute -TargetType "VirtualMachine" -Name "05-last-backup" New-CustomAttribute -TargetType "VirtualMachine" -Name "06-vbr-restore-points" New-CustomAttribute -TargetType "VirtualMachine" -Name "07-vbr-job-options"
The script prerequisites:
- script easier to run directly from veeambr server.
- veeambr server should have network access to vcsa by 443 port
- script can be placed into Windows Scheduled Tasks (mandatory to tick “run with highest privileges”, user under which to run the script should be Local Administrator [domain user should be placed into Local Administrators of VBR])
- it considered that powerCLI is installed on veeambr.itforce.local server by default into default path
- $jobsession and $tasksession can be different in case when one job contains several VM/tasks
Result:
Script:
.'C:\Program Files (x86)\VMware\Infrastructure\PowerCLI\Scripts\Initialize-PowerCLIEnvironment.ps1' Add-PSSnapin VeeamPSSnapin connect-viserver vcsa.itforce.local Connect-VBRServer -server veeambr.itforce.local $jobs=get-vbrjob foreach ($job in $jobs) { $jobsession = $job.FindLastSession() $check01=Get-VBRJob -name $job.name | Get-VBRJobObject | select name if ($check01 -ne $null) { foreach ($item in $check01) { $full=(Get-VBRRestorePoint -name $item.name | where {$_.type -eq "Full"}).count $increamental=(Get-VBRRestorePoint -name $item.name | where {$_.type -eq "Increment"}).count write-host "Full backup restore points available for VM named " $item.name "are "$full write-host "Incremental backup restore points available for VM named " $item.name "are "$increamental $a="Full backup restore points available for VM named " + $item.name + " are " + $full $b="Incremental backup restore points available for VM named " + $item.name + " are " + $increamental $annotation=$a+"; " + $b get-vm $item.Name | Set-Annotation -CustomAttribute "06-vbr-restore-points" -Value $annotation $tasksession = $jobsession | get-vbrtasksession -name $item.name $session = $tasksession | Select @{Name="VMName"; Expression = {$_.Name}}, @{Name="JobName"; Expression = {$_.JobName}}, @{Name="StartTime"; Expression = {$_.Progress.StartTimeLocal}}, @{Name="StopTime"; Expression = {$_.Progress.StopTimeLocal}}, @{Name="DurationHHMMSS"; Expression = {$_.Progress.Duration}}, @{Name="AvgSpeedMBs"; Expression = {[Math]::Round($_.Progress.AvgSpeed/1MB,2)}}, @{Name="TotalGB"; Expression = {[Math]::Round($_.Progress.ProcessedSize/1GB,2)}}, @{Name="ProcessedGB"; Expression = {[Math]::Round($_.Progress.ProcessedUsedSize/1GB,2)}}, @{Name="DataReadGB"; Expression = {[Math]::Round($_.Progress.ReadSize/1GB,2)}}, @{Name="TransferredGB"; Expression = {[Math]::Round($_.Progress.TransferedSize/1GB,2)}}, Status $lastsessiondetails="Last backup details: " + "VM Name is " + $session.VMName + "; Job Name is " +$session.JobName + "; Start Time is " +$session.StartTime + "; Stop time is " + $session.StopTime + "; Duration is " + $session.DurationHHMMSS + "; Average speed in Mb/s is " + $session.AvgSpeedMBs + "; Total in Gb is " + $session.TotalGB + "; Processed in Gb is " + $session.ProcessedGB + "; Data Read in Gb is " + $session.DataReadGB + "; Transferred Gb is " + $session.TransferredGB + "; Session Status is " + $session.Status $lastsessiondetails get-vm $item.Name | Set-Annotation -CustomAttribute "05-last-backup" -Value $lastsessiondetails get-vm $item.Name | Set-Annotation -CustomAttribute "07-vbr-job-options" -Value $job.ScheduleOptions write-host "------------------------------------------------------------------------------" } } }