PowerShell script exchange
Post Reply
amccloud
Service Provider
Posts: 10
Liked: never
Joined: Sep 27, 2018 4:47 pm
Full Name: Anthony McCloud
Contact:

Modify All Backup Job Notifications

Post by amccloud »

I need to change the notification options of all my backup jobs. Globally I want all emails to a certain address, and I want all jobs configured to send only errors on last retry to a different address. I run this code and it looks like it completed successfully, but when I check the jobs in the GUI nothing has been modified. What am I doing wrong?

Code: Select all

Add-PSSnapin -Name VeeamPSSnapIn -ErrorAction SilentlyContinue
$Jobs = Get-VBRJob
Foreach ($Job in $Jobs)
{
$notifications = New-VBRNotificationOptions -EnableAdditionalNotification -AdditionalAddress "email@domain.com" -UseNotificationOptions -NotifyOnError -NotifyOnLastRetryOnly
Set-VBRNotificationOptions -NotificationOptions $notifications
}
veremin
Product Manager
Posts: 20413
Liked: 2301 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Modify All Backup Job Notifications

Post by veremin »

Check this example:

Code: Select all

Asnp VeeamPSSnapin
$Job = Get-VBRJob -name "Name of your job"
$Options = $Job.GetOptions()
$Options.NotificationOptions.SendEmailNotification2AdditionalAddresses = $True
$Options.NotificationOptions.EmailNotificationAdditionalAddresses = "Someemail@dot.com"
$Options.NotificationOptions.EmailNotifyOnLastRetryOnly = $False
$Options.NotificationOptions.UseCustomEmailNotificationOptions = $True
Set-VBRJobOptions -Job $Job -Options $Options
Thanks!
amccloud
Service Provider
Posts: 10
Liked: never
Joined: Sep 27, 2018 4:47 pm
Full Name: Anthony McCloud
Contact:

Re: Modify All Backup Job Notifications

Post by amccloud »

That works and thanks for your help, but your example doesn't look like those given here https://helpcenter.veeam.com/docs/backu ... l?ver=95u4. Not sure if I'm just looking in the wrong spot, or what the deal is. Either way, thanks again.
veremin
Product Manager
Posts: 20413
Liked: 2301 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Modify All Backup Job Notifications

Post by veremin »

The example works, but probably a bit differently from what you've expected.

It modifies notification options template (VBRNotificationOptions object) created in the first line. It doesn't have any associations with jobs, therefore job schedule stays intact.

Also, backup, backup copy, replication jobs have notification options of different type (CDomNotificationOptions). Because of that they must be configured differently.

Thanks!
Post Reply

Who is online

Users browsing this forum: No registered users and 27 guests