Hi – I’m Mike – you may remember me from such blogs as, oh this one last year! I know, it’s been a while since I’ve written anything, moreso, published anything. It’s been a hectic couple of months and I’ve got a ton of drafts sitting just waiting to be touched up so stay tuned – I promise to be a bit more visible in the next coming weeks! Anyways I called this a quick fix so I guess I should get to the point…
There is a setting within the notification options inside Veeam Backup and Replication that allows you to write some details to a processed VMs annotations section. Now I’ve never had a use for this…until now. I was reporting on a wide variety of things in regards to specific VMs, and having the last successful backup was one of the things that I wanted to report on. This was within an asp.net application, and dropping to PowerShell and loading up the Veeam cmdlets was something I just didn’t feel like coding within the application. Also, accessing the Veeam REST API was out of the question seeing as these VMs were being processed by Veeam Standard lisenses – REST is only available within Veeam’s Enterprise Plus offering. Since I was already connected the vSphere API to gather a bunch of information such as CPU and Memory usage I thought by having Veeam write the last successful backup to the Notes field within vSphere would be a good alternative, as I could just gather that info with the same API calls I was making to vSphere.
One problem presented itself – I had roughly 50 different jobs within the Veeam Backup and Replication deployment that needed to be updated in order to make it happen. Naturally I looked to automation for the solution – and I found it with PowerShell. In order to completely enable this feature, and turn off the ‘append’ option you have to touch two different spots within Veeam PowerShell; one, the Set-VBRJobAdvancedViOptions (to enable the actual writing to VM Attributes) and another by setting the VmNotesAppend flag within the ViSourceOptions object.
Its a simple script, and honestly you probably don’t care, or didn’t read any of the introduction stuff above – I know how things work, you came here for the script – well, here its…
1 2 3 4 5 6 7 8 9 |
$jobs = Get-VBRJob foreach ($job in $jobs) { $job | Set-VBRJobAdvancedViOptions -SetResultsToVmAttribute $True $joboptions = $job.GetOptions() $joboptions.ViSourceOptions.VmNotesAppend = $False $job.SetOptions($joboptions) } |
There you have it! A simple script that peels through all the VBR Jobs within a console, enables the writing to the VM Attribute, and disables the append flag. An easy script but useful none the less 🙂
This is great, thanks
no problem – glad to share! I knew at least one person would find some tidbit of helpful info in there 🙂
@mwpreston:disqus How to set what details to be written on the “Notes” VCenter server Attributes ?
foreach ($job in $jobs)
{
$job | Set-VBRJobAdvancedViOptions -SetResultsToVmAttribute $True
$joboptions = $job.GetOptions()
#Name of the Attribute : default is “Note” :
$joboptions.ViSourceOptions.VmAttributeName = “Last Backup”
$joboptions.ViSourceOptions.VmNotesAppend = $False
$job.SetOptions($joboptions)
}