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 &#8220;05-last-backup&#8221;, &#8220;06-vbr-restore-points&#8221;, &#8220;07-vbr-job-options&#8221;; vcsa is named as  &#8220;vcsa.itforce.local&#8221;; VBR is named as &#8220;veeambr.itforce.local&#8221;) 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  <span><a href="https://www.itforce.mn/index.php/2021/11/30/powershell-script-to-sync-information-between-veeam-backup-and-replication-and-vcsa/" class="readmore">Continue reading &rarr;</a></span>{"id":1650,"date":"2021-11-30T17:13:01","date_gmt":"2021-11-30T09:13:01","guid":{"rendered":"https:\/\/www.itforce.mn\/?p=1650"},"modified":"2021-11-30T22:31:04","modified_gmt":"2021-11-30T14:31:04","slug":"powershell-script-to-sync-information-between-veeam-backup-and-replication-and-vcsa","status":"publish","type":"post","link":"https:\/\/www.itforce.mn\/index.php\/2021\/11\/30\/powershell-script-to-sync-information-between-veeam-backup-and-replication-and-vcsa\/","title":{"rendered":"Draft of powershell script to sync information between Veeam Backup and Replication and vcsa"},"content":{"rendered":"<p>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 &#8220;05-last-backup&#8221;, &#8220;06-vbr-restore-points&#8221;, &#8220;07-vbr-job-options&#8221;; vcsa is named as\u00a0 &#8220;vcsa.itforce.local&#8221;; VBR is named as &#8220;veeambr.itforce.local&#8221;)<\/p>\n<p>To pre-create custom attributes for each VM in your vcsa:<\/p>\n<pre>connect-viserver vcsa.itforce.local\r\nNew-CustomAttribute -TargetType \"VirtualMachine\" -Name \"05-last-backup\"\r\nNew-CustomAttribute -TargetType \"VirtualMachine\" -Name \"06-vbr-restore-points\"\r\nNew-CustomAttribute -TargetType \"VirtualMachine\" -Name \"07-vbr-job-options\"\r\n\r\n<\/pre>\n<p>The script prerequisites:<\/p>\n<ol>\n<li>script easier to run directly from veeambr server.<\/li>\n<li>veeambr server should have network access to vcsa by 443 port<\/li>\n<li>script can be placed into Windows Scheduled Tasks (mandatory to tick &#8220;run with highest privileges&#8221;, user under which to run the script should be Local Administrator [domain user should be placed into Local Administrators of VBR])<\/li>\n<li>it considered that powerCLI is installed on veeambr.itforce.local server by default into default path<\/li>\n<li>$jobsession and $tasksession can be different in case when one job contains several VM\/tasks<\/li>\n<\/ol>\n<p>Result:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1664\" src=\"http:\/\/www.itforce.mn\/wp-content\/uploads\/2021\/11\/sample2.jpg\" alt=\"\" width=\"448\" height=\"319\" \/><\/p>\n<p>Script:<\/p>\n<pre>.'C:\\Program Files (x86)\\VMware\\Infrastructure\\PowerCLI\\Scripts\\Initialize-PowerCLIEnvironment.ps1'\r\nAdd-PSSnapin VeeamPSSnapin\r\nconnect-viserver vcsa.itforce.local\r\nConnect-VBRServer -server veeambr.itforce.local\r\n$jobs=get-vbrjob\r\nforeach ($job in $jobs)\r\n{\r\n$jobsession = $job.FindLastSession()\r\n$check01=Get-VBRJob -name $job.name | Get-VBRJobObject | select name\r\nif ($check01 -ne $null)\r\n {\r\n foreach ($item in $check01)\r\n  {\r\n  $full=(Get-VBRRestorePoint -name $item.name | where {$_.type -eq \"Full\"}).count\r\n  $increamental=(Get-VBRRestorePoint -name $item.name | where {$_.type -eq \"Increment\"}).count\r\n  write-host \"Full backup restore points available for VM named \" $item.name \"are \"$full\r\n  write-host \"Incremental backup restore points available for VM named \" $item.name \"are \"$increamental\r\n  $a=\"Full backup restore points available for VM named \" + $item.name + \" are \" + $full\r\n  $b=\"Incremental backup restore points available for VM named \" + $item.name + \" are \" + $increamental\r\n  $annotation=$a+\"; \" + $b\r\n  get-vm $item.Name | Set-Annotation -CustomAttribute \"06-vbr-restore-points\" -Value $annotation\r\n    \r\n  $tasksession = $jobsession | get-vbrtasksession -name $item.name\r\n  $session = $tasksession | Select @{Name=\"VMName\"; Expression = {$_.Name}},\r\n    @{Name=\"JobName\"; Expression = {$_.JobName}},\r\n    @{Name=\"StartTime\"; Expression = {$_.Progress.StartTimeLocal}},\r\n    @{Name=\"StopTime\"; Expression = {$_.Progress.StopTimeLocal}},\r\n    @{Name=\"DurationHHMMSS\"; Expression = {$_.Progress.Duration}},                    \r\n    @{Name=\"AvgSpeedMBs\"; Expression = {[Math]::Round($_.Progress.AvgSpeed\/1MB,2)}},\r\n    @{Name=\"TotalGB\"; Expression = {[Math]::Round($_.Progress.ProcessedSize\/1GB,2)}},\r\n    @{Name=\"ProcessedGB\"; Expression = {[Math]::Round($_.Progress.ProcessedUsedSize\/1GB,2)}},\r\n    @{Name=\"DataReadGB\"; Expression = {[Math]::Round($_.Progress.ReadSize\/1GB,2)}},\r\n    @{Name=\"TransferredGB\"; Expression = {[Math]::Round($_.Progress.TransferedSize\/1GB,2)}},\r\n    Status\r\n  $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\r\n  $lastsessiondetails\r\n  get-vm $item.Name | Set-Annotation -CustomAttribute \"05-last-backup\" -Value $lastsessiondetails\r\n  get-vm $item.Name | Set-Annotation -CustomAttribute \"07-vbr-job-options\" -Value $job.ScheduleOptions\r\n  write-host \"------------------------------------------------------------------------------\" \r\n  \r\n \r\n  \r\n  }\r\n }\r\n}\r\n\r\n\r\n\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":null,"protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[19],"tags":[],"class_list":["post-1650","post","type-post","status-publish","format-standard","hentry","category-powercli"],"_links":{"self":[{"href":"https:\/\/www.itforce.mn\/index.php\/wp-json\/wp\/v2\/posts\/1650","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.itforce.mn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.itforce.mn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.itforce.mn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.itforce.mn\/index.php\/wp-json\/wp\/v2\/comments?post=1650"}],"version-history":[{"count":13,"href":"https:\/\/www.itforce.mn\/index.php\/wp-json\/wp\/v2\/posts\/1650\/revisions"}],"predecessor-version":[{"id":1682,"href":"https:\/\/www.itforce.mn\/index.php\/wp-json\/wp\/v2\/posts\/1650\/revisions\/1682"}],"wp:attachment":[{"href":"https:\/\/www.itforce.mn\/index.php\/wp-json\/wp\/v2\/media?parent=1650"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.itforce.mn\/index.php\/wp-json\/wp\/v2\/categories?post=1650"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.itforce.mn\/index.php\/wp-json\/wp\/v2\/tags?post=1650"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}